Sereja has painted *n* distinct points on the plane. The coordinates of each point are integers. Now he is wondering: how many squares are there with sides parallel to the coordinate axes and with points painted in all its four vertexes? Help him, calculate this number.
The first line contains integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>). Each of the next *n* lines contains two integers *x*<sub class="lower-index">*i*</sub>, *y*<sub class="lower-index">*i*</sub> (0 ≤ *x*<sub class="lower-index">*i*</sub>, *y*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">5</sup>), the integers represent the coordinates of the *i*-th point. It is guaranteed that all the given points are distinct.
import io, os, sys
from collections import defaultdict, deque, Counter
from functools import cache
from math import floor, ceil, sqrt
from bisect import bisect_left as bs
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
og_print, print = print, lambda x: sys.stdout.write(repr(x) + "\n")

n = int(input())
squares = 0

# a list of y's for each x
xty = defaultdict(set)
# list of x's that have a given y
ytx = defaultdict(set)


for _ in range(n):
    x, y = map(int, input().split())
    xty[x].add(y)
    ytx[y].add(x)


for x in xty:
    ys = xty[x]
    for y in ys:
        xs = ytx[y]

        if len(ys) < len(xs):
            for y2 in ys:
                if y == y2:
                    continue
                s = abs(y - y2)
                if x + s in xty:
                    l = xyt[x + s]
                    if y in l and y2 in l:
                        squares += 1
        else:
            for x2 in xs:
                if x == x2:
                    continue
                s = abs(x - x2)
                if y + s in ytx:
                    l = ytx[y + s]
                    if x in l and x2 in l:
                        squares += 1


print(squares // 2)


