n,k,*d=$<.read.split.map &:to_i c=0 n.times{|i|o=i;(o>i&&c+=1;d[o],o=p,l-1)while l=d[o]} puts c>k||c+k&1>0?:NO:'YES'