N,K=map(int,input().split()) D=[ x-1 for x in map(int,input().split())] Z=[int(D[i]==i) for i in range(N)].count(0) #print(Z) swaptime=(Z+1)//2 #print(K-swaptime) print(('YES','NO')[K-swaptime<0 or (K-swaptime)%2==1])