import sys def _solve(N, K, D): G = {} for i, v in enumerate(D, 1): G.setdefault(i, set()).add(v) G.setdefault(v, set()).add(i) # print(G) c = 0 used = set() for i in range(1, N + 1): if i in used: continue if i not in G: continue e = 0 s = [i] while s: cur = s.pop() for j in G[cur]: if j in used: continue used.add(j) e += 1 if j not in G: continue s.append(j) c += e - 1 # print(K, c) return K >= c and (K - c) % 2 == 0 def solve(in_): N, K = map(int, next(in_).split()) D = list(map(int, next(in_).split())) return _solve(N, K, D) def main(): answer = solve(sys.stdin.buffer) print('YES' if answer else 'NO') if __name__ == '__main__': main()