n = gets.to_i
w = []
n.times do |i|
  w[i] = gets.split.map(&:to_i)
end
a = 1000000001
b = 1000000001
cost = 1
w.sort.reverse.each do |x, y|
  cost += 1 if a < x || b < y
  a = x
  b = y
end

puts cost
