import java.util.Scanner; public class Main { private static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); long k = sc.nextLong(); int[] l = new int[200010]; boolean[] b = new boolean[200010]; for (int i = 1;i <= n;i++) { l[i] = sc.nextInt(); } int r = 0; for (int i = 1;i <= n;i++) { if (b[i]) continue; int s = i; int j = l[i]; int c = 0; b[i] = true; while (true) { if (j==s) break; b[j] = true; j = l[j]; c++; } r += c; b[i] = true; } if (r<=k) { if ((k-r)%2==0) { System.out.println("YES"); } else { System.out.println("NO"); } } else { System.out.println("NO"); } } }