N, K = gets.split.map(&:to_i) D = gets.split.map(&:to_i).map{|d| d - 1 } min = D.each_index.inject(0) do |s, i| until i == D[i] d = D[i] D[i] = D[d] D[d] = d s += 1 end s end puts min <= K && (K - min).even? ? :YES : :NO