import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # あ、隣接じゃない N,K,*D = map(int,read().split()) visited = [0] * (N+1) cycle = 0 for n in range(1,N+1): if not visited[n]: cycle += 1 while True: n = D[n-1] if visited[n]: break visited[n] = 1 x = N - cycle answer = 'YES' if (K>=x) and ((K-x)%2 == 0) else 'NO' print(answer)