N, K = map(int, input().split()) D = [0] D.extend(list(map(int, input().split()))) for i in range(1, N+1): while D[i] != i: temp = D[i] D[i], D[temp] = D[temp], D[i] K -= 1 if K < 0: break if K & 1 == 1 or K < 0: print('NO') else: print('YES')