# frozen_string_literal: true N, K = gets.chomp.split.map(&:to_i) (N - 1).times { gets } RESULT = N < K ? -1 : (K - 1) puts RESULT