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