require 'set'
def check_and_put(x, y)
  return 0 if XS[x] != nil && XS[x].include?(y)
  XS[x] ||= Set[]
  XS[x] << y
  YS[y] ||= Set[]
  YS[y] << x
  1
end

N = gets.to_i
points = N.times.map{ gets.split.map(&:to_i) }
XS = {}
YS = {}
points.each do |point|
  check_and_put(point[0], point[1])
end

score = 0
XS.keys.each do |x|
  y_set = XS[x]
  next if y_set.size == 1
  x_set = Set[]
  y_set.each do |y|
    x_set.merge(YS[y] || Set[])
  end
  x_set.to_a.product(y_set.to_a).each do |nx, ny|
    score += check_and_put(nx, ny)
  end
end
puts score
