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