n,k,*d=$<.read.split.map &:to_i x,c=[],0 n.times{|i|x[d[i]]=i} n.times{|i|(a=d[i])==(m=i+1)||(c+=1;d[x[m]],d[i],x[a],x[m]=a,m,x[m],i)} puts c<=k&&1&(k^c)<1?:YES:'NO'