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