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