n, k = gets.split().map(&:to_i) nums = gets.split().map(&:to_i) a,b,score = 0,0,0 nums.each_with_index do |c,i| if i+1 == c next elsif i+1 == nums[c-1] a += 1 elsif i+1 != nums[c-1] b += 1 end end score += a / 2 if a > 1 score += b - 1 if b > 2 if score % 2 == 0 && k % 2 == 0 && score <= k puts "YES" elsif score % 2 != 0 && k % 2 != 0 && score <= k puts "YES" else puts "NO" end