// Arup Guha
// 10/6/2017
// Solution to 2017 NAQ Problem G: Greeting Card

import java.util.*;
import java.io.*;

public class greetingcard_arup {

	final public static int DISTANCE = 2018;
	public static ArrayList<int[]> delta;

	public static int n;
	public static long[][] pts;


	public static void main(String[] args) throws Exception {

		delta = new ArrayList<int[]>();

		// No need to be smart here - just run a for loop to find all (x,y) s.t. x^2 + y^2 = 2018.
		for (int x=-DISTANCE; x<=DISTANCE; x++) {
			int ysq = DISTANCE*DISTANCE - x*x;
			int y = (int)(Math.sqrt(ysq) + .1e-9);
			if (x*x + y*y == DISTANCE*DISTANCE) {
				delta.add(new int[]{x,y});
				if (y != 0) delta.add(new int[]{x,-y});
			}
		}

		// Store look up table for each unique x.
		HashMap<Long,Integer> xMap = new HashMap<Long,Integer>();
		int ID = 0;

		// Store the points, initially.
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(stdin.readLine());
		pts = new long[n][2];
		for (int i=0; i<n; i++) {
			StringTokenizer tok = new StringTokenizer(stdin.readLine());
			pts[i][0] = Integer.parseInt(tok.nextToken());
			pts[i][1] = Integer.parseInt(tok.nextToken());

			// Store a new x, if necessary.
			if (!xMap.containsKey(pts[i][0])) xMap.put(pts[i][0], ID++);
		}

		// Store each y associated with each x here.
		HashSet[] yLists = new HashSet[ID];
		for (int i=0; i<yLists.length; i++)
			yLists[i] = new HashSet<Long>();

		// Now, store all pts into the yLists.
		for (int i=0; i<n; i++)
			yLists[xMap.get(pts[i][0])].add(pts[i][1]);

		int res = 0;

		// Now, loop through all pts, and all possible dx,dy vectors.
		for (int i=0; i<n; i++) {
			for (int j=0; j<delta.size(); j++) {

				// Get where we go from pt[i] moving in direction j.
				int[] move = delta.get(j);
				long x = pts[i][0] + move[0];
				long y = pts[i][1] + move[1];

				// Definitely not in our list.
				if (!xMap.containsKey(x)) continue;

				// Add 1 if this candidate point is in the list.
				if (yLists[xMap.get(x)].contains(y))
					res++;
			}
		}

		// Divide by 2 since we counted each pair of points twice.
		System.out.println(res/2);
	}
}