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 if d[d[i] - 1] == i count += 1 else count2 += 1 end end # p count # p count2 if count2 == 0 && k % 2 == 0 puts "YES" elsif count2 == 0 puts "NO" elsif k - count / 2 - count2 + 1 >= 0 && (k - count / 2 - count2 + 1) % 2 == 0 puts "YES" else puts "NO" end