n, m = gets.chomp.split(" ").map(&:to_i) hash = Hash.new(0) count = 0 iru = Hash.new(0) n.times do b, c = gets.chomp.split(" ").map(&:to_i) count += 1 if hash[c] >= 1 count -= 1 if iru[c] == b && hash[c] >= 1 iru[c] = b hash[c] += 1 end puts count