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
points.each do |x, y|
  x_siblings = YS[y].select{|i| i != x }
  y_siblings = XS[x].select{|i| i != y }
  x_siblings.product(y_siblings).each do |nx, ny|
    score += check_and_put(nx, ny)
  end
end
puts score
