import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long K = sc.nextLong(); int[] D = new int[N]; for (int i = 0; i < N; ++i) { D[i] = sc.nextInt() - 1; } boolean[] vis = new boolean[N]; int cnt = 0; for (int i = 0; i < N; ++i) { if (vis[i]) continue; int cur = i; vis[i] = true; while (D[cur] != i) { cur = D[cur]; vis[cur] = true; ++cnt; } } if (cnt % 2 != K % 2 || cnt > K) { System.out.println("NO"); } else { System.out.println("YES"); } } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }