n,k = gets.split.map(&:to_i) d = gets.split.map(&:to_i) d = d.map { |v| v-1 } cnt = 0 n.times do |i| if d[i] == i next else t = d.index(i) tm = d[t] d[t] = d[i] d[i] = tm cnt += 1 end end a = k - cnt if a < 0 puts "NO" elsif cnt == k || a % 2 == 0 puts "YES" else puts "NO" end