N, K = map(int, input().split()) D = [0] + list(map(int, input().split())) done = [0] * (N + 1) cnt = 0 for i in range(1, N+1): if D[i] == i: continue if not done[D[i]] or not done[i]: cnt += 1 done[D[i]] = done[i] = True yes = cnt <= K and cnt % 2 == K % 2 print('YES' if yes else 'NO')