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