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