N,K = map(int, input().split()) D = [ x-1 for x in map(int, input().split())] cnt = 0 for n in range(N): while D[n] != n: t = D[n] D[n], D[t] = D[t], D[n] cnt += 1 print('NO' if K < cnt or (K-cnt)%2 else 'YES')