N, K = map(int, input().split()) D = list(map(lambda x: int(x) - 1, input().split())) ans = 0 for i in range(N): if D[i] != i: D[D[i]] = D[i] ans += 1 if ans > K or (ans - K) % 2: print('NO') else: print('YES')