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