import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class _482 { public static void main(String[] args) throws IOException { new _482().solve(); } void solve() throws IOException { try (final Scanner in = new Scanner(System.in)) { int n = in.nextInt(); long k = in.nextLong(); int[] D = new int[n]; for (int i = 0; i < n; i++) { D[i] = in.nextInt() - 1; } boolean[] vis = new boolean[n]; for (int i = 0; i < n; i++) if (!vis[i]) { int c = 1; for (int j = D[i]; j != i; j = D[j], c++) vis[j] = true; k -= c - 1; } System.out.println(k >= 0 && k % 2 == 0 ? "YES" : "NO"); } } // for debug static void dump(Object... o) { System.err.println(Arrays.deepToString(o)); } }