Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (xi, yi).

They need to arrange a plan, but there are some difficulties on their way. As you know, Doctor Manhattan considers the distance between watchmen i and j to be |xi - xj| + |yi - yj|. Daniel, as an ordinary person, calculates the distance using the formula <image>.

The success of the operation relies on the number of pairs (i, j) (1 ≤ i < j ≤ n), such that the distance between watchman i and watchmen j calculated by Doctor Manhattan is equal to the distance between them calculated by Daniel. You were asked to compute the number of such pairs.

Input

The first line of the input contains the single integer n (1 ≤ n ≤ 200 000) — the number of watchmen.

Each of the following n lines contains two integers xi and yi (|xi|, |yi| ≤ 109).

Some positions may coincide.

Output

Print the number of pairs of watchmen such that the distance between them calculated by Doctor Manhattan is equal to the distance calculated by Daniel.

Examples

Input

3
1 1
7 5
1 5


Output

2


Input

6
0 0
0 1
0 2
-1 1
0 1
1 1


Output

11

Note

In the first sample, the distance between watchman 1 and watchman 2 is equal to |1 - 7| + |1 - 5| = 10 for Doctor Manhattan and <image> for Daniel. For pairs (1, 1), (1, 5) and (7, 5), (1, 5) Doctor Manhattan and Daniel will calculate the same distances.

import java.io.IOException;
import java.util.*;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.*;

/**
 * http://codeforces.com/problemset/problem/650/A #datastructures
 *
 * Manhattan and Euclidean distance will be equal if x1==x2 or y1==y2. Iterate
 * over points and store the number of occurences of each x and y coordinate, as
 * well as number of occurences of each point. For point p(x,y), increase the
 * answer by the number of seen coordinates x and y, but decrease it by number
 * of identical points t(x,y) already seen - because otherwise they would be
 * counted twice.
 *
 * Time complexity: O(n), Memory complexity: O(n)
 */
public class Watchmen {

	public static void main(String[] args) throws IOException {
		Reader r = new Reader();
		Writer w = new Writer();

		int n = r.nextInt();
		int x, y;

		Point<Integer> p;
		HashMap<Integer, Integer> xMap = new HashMap<>();
		HashMap<Integer, Integer> yMap = new HashMap<>();
		HashMap<Point<Integer>, Integer> points = new HashMap<>();

		long ans = 0L;

		for (int i = 0; i < n; ++i) {
			x = r.nextInt();
			y = r.nextInt();
			p = new Point<Integer>(x, y);

			if (xMap.containsKey(x))
				ans += xMap.get(x);
			if (yMap.containsKey(y))
				ans += yMap.get(y);

			if (points.containsKey(p))
				ans -= points.get(p);

			points.putIfAbsent(p, 0);
			points.put(p, points.get(p) + 1);
			xMap.putIfAbsent(x, 0);
			yMap.putIfAbsent(y, 0);
			xMap.put(x, xMap.get(x) + 1);
			yMap.put(y, yMap.get(y) + 1);
		}
		w.println(ans);

		w.close();
	}

}
/**
 * Class for representing 2D points.
 * 
 * @param <T> Type of coordinates (e.g. Integer or Double).
 */
class Point<T extends Comparable<T>> implements Comparable<Point<T>> {
	public T x, y;

	public Point(T x, T y) {
		this.x = x;
		this.y = y;
	}

	@Override
	public int compareTo(Point<T> p) {
		int cmp = this.x.compareTo(p.x);
		return (cmp != 0) ? cmp : this.y.compareTo(p.y);
	}

	@Override
	public int hashCode() {
		int result = 17;
		result = 31 * result + x.hashCode();
		result = 31 * result + y.hashCode();
		return result;
	}

	@Override
	public boolean equals(Object o) {
		if (o == this)
			return true;
		if (!(o instanceof Point<?>))
			return false;
		@SuppressWarnings("unchecked")
		Point<T> p = (Point<T>) o;
		return p.x.equals(x) && p.y.equals(y);
	}
}


/**
 * Custom class for fast input that uses BufferedReader and StringTokenizer.
 */
class Reader {
	private BufferedReader br;
	private StringTokenizer st;

	public Reader() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	private String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public int[] nextIntArray(int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; ++i)
			arr[i] = nextInt();
		return arr;
	}

	public ArrayList<Integer> nextIntArrayList(int size) {
		ArrayList<Integer> lst = new ArrayList<>(size);
		for (int i = 0; i < size; ++i)
			lst.add(nextInt());
		return lst;
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public long[] nextLongArray(int size) {
		long[] arr = new long[size];
		for (int i = 0; i < size; ++i)
			arr[i] = nextLong();
		return arr;
	}

	public ArrayList<Long> nextLongArrayList(int size) {
		ArrayList<Long> lst = new ArrayList<>(size);
		for (int i = 0; i < size; ++i)
			lst.add(nextLong());
		return lst;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public double[] nextDoubleArray(int size) {
		double[] arr = new double[size];
		for (int i = 0; i < size; ++i)
			arr[i] = nextDouble();
		return arr;
	}

	public String nextString() {
		return next();
	}

	public String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}


/**
 * Custom class used for fast output.
 */
class Writer {
	private final BufferedWriter bw;

	public Writer() {
		this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
	}

	public void print(Object object) throws IOException {
		bw.append("" + object);
	}

	public void println(Object object) throws IOException {
		print(object);
		bw.append("\n");
	}

	public void close() throws IOException {
		bw.close();
	}

}
