n, k = gets.strip.split(' ').map(&:to_i) d = gets.strip.split(' ').map(&:to_i) count = 0 count2 = 0 (0...n).each do |i| next if d[i] - 1 == i # print "#{i}:d[i]=#{d[i]} d[d[i] - 1]=#{d[d[i] - 1]}" if d[d[i] - 1] == i + 1 count += 1 else count2 += 1 end end # p count # p count2 if count2 == 0 if k - count / 2 >= 0 && (k - count / 2) % 2 == 0 puts "YES" else puts "NO" end elsif k - count / 2 - count2 + 1 >= 0 && (k - count / 2 - count2 + 1) % 2 == 0 puts "YES" else puts "NO" end