n = gets.strip.to_i
town = []
n.times do
  x, y = gets.strip.split.map(&:to_i)
  town << [x, y]
end

# pp town

town.each do |x, y|
  now = [x, y]
  gone = [[x, y]]
  can = []
  town_clone = town.clone
  town_clone = town_clone - gone

  loop do
    town_clone = town_clone - can - gone
    town_clone.each do |xx, yy|
      can << [xx, yy] if !can.include?([xx, yy]) && !gone.include?([xx, yy]) && ((xx < now[0] && yy < now[1]) || (xx > now[0] && yy > now[1]))
    end

    break if can.length == 0

    now = can.shift
    gone << now
    # pp now
  end
  # pp "#{gone.length}, gone: #{gone}"
  # pp "================="
  puts gone.length
end
