n,k,*d=$<.read.split.map &:to_i x,c=[],0;d.each_with_index{|a,i|x[a]=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