n, k = [int(i) for i in input().split()] d = [int(i) for i in input().split()] e = [0 for i in range(n)] for i, dd in enumerate(d): e[dd] = i used_indices = set() hoge = list() for i in range(n): x = i y = 0 while x not in used_indices: used_indices.add(x) x = e[x] y += 1 if y > 0: hoge.append(y) x = sum(a - 1 for a in hoge) if x % 2 == k % 2 and x <= k: print('YES') else: print('NO')