There are n points on the plane, the i-th of which is at (x_i, y_i). Tokitsukaze wants to draw a strange rectangular area and pick all the points in the area.

The strange area is enclosed by three lines, x = l, y = a and x = r, as its left side, its bottom side and its right side respectively, where l, r and a can be any real numbers satisfying that l < r. The upper side of the area is boundless, which you can regard as a line parallel to the x-axis at infinity. The following figure shows a strange rectangular area.

<image>

A point (x_i, y_i) is in the strange rectangular area if and only if l < x_i < r and y_i > a. For example, in the above figure, p_1 is in the area while p_2 is not.

Tokitsukaze wants to know how many different non-empty sets she can obtain by picking all the points in a strange rectangular area, where we think two sets are different if there exists at least one point in one set of them but not in the other.

Input

The first line contains a single integer n (1 ≤ n ≤ 2 × 10^5) — the number of points on the plane.

The i-th of the next n lines contains two integers x_i, y_i (1 ≤ x_i, y_i ≤ 10^9) — the coordinates of the i-th point.

All points are distinct.

Output

Print a single integer — the number of different non-empty sets of points she can obtain.

Examples

Input

3
1 1
1 2
1 3


Output

3


Input

3
1 1
2 1
3 1


Output

6


Input

4
2 1
2 2
3 1
3 2


Output

6

Note

For the first example, there is exactly one set having k points for k = 1, 2, 3, so the total number is 3.

For the second example, the numbers of sets having k points for k = 1, 2, 3 are 3, 2, 1 respectively, and their sum is 6.

For the third example, as the following figure shows, there are

  * 2 sets having one point; 
  * 3 sets having two points; 
  * 1 set having four points. 



Therefore, the number of different non-empty sets in this example is 2 + 3 + 0 + 1 = 6.

<image>
import java.util.*;
import java.io.*;

public class Solution{

	public static Integer INT(String s){
		return Integer.parseInt(s);
	}

	public static Long LONG(String s){
		return Long.parseLong(s);
	}

	//====================================================================================================================

	public static class Point implements Comparable<Point>{
		int x, y;
		Point(int x, int y) {
			this.x=x;
			this.y=y;
		} 
		public int compareTo(Point obj) {
			if(this.y==obj.y)
				return this.x-obj.x;
			return obj.y-this.y;
		}
		public String toString() {
			return "("+x+" "+y+")";
		}
	}

	public static void main(String args[]) throws IOException {

		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));	Scanner in=new Scanner(System.in); StringBuilder out=new StringBuilder();
		
		int n=in.nextInt();

		Point p[]=new Point[n];
		for(int i=0; i<n; i++)
			p[i]=new Point(in.nextInt(), in.nextInt());

		compress(p);

		Arrays.sort(p);
		// System.out.println(Arrays.toString(p));
		SegmentTree obj=new SegmentTree(n);

		long count=0;

		int y=-1, x=0;

		for(Point item: p) {

			count += (obj.query(0, item.x-1)+1L)*(obj.query(item.x+1, n-1)+1L);

			if(item.y==y)
				count -= 1L*obj.query(0, x)*obj.query(item.x, n-1);

			obj.update(item.x);

			y=item.y;
			x=item.x;
		}

		System.out.println(count);
	}

	public static void compress(Point p[]) {

		TreeSet<Integer> set1=new TreeSet<>(),
						 set2=new TreeSet<>();

		for(Point item: p) {
			set1.add(item.x);
			set2.add(item.y);
		}

		int i;

		HashMap<Integer, Integer> map1=new HashMap<>();
		i=0;
		while(!set1.isEmpty())
			map1.put(set1.pollFirst(), i++);

		HashMap<Integer, Integer> map2=new HashMap<>();
		i=0;
		while(!set2.isEmpty())
			map2.put(set2.pollFirst(), i++);

		for(Point item: p) {
			item.x=map1.get(item.x);
			item.y=map2.get(item.y);
		}
	}
}

class SegmentTree {

	int st[], a[], n;

	SegmentTree(int n) {
		st=new int[4*n];
		a=new int[n];
		this.n=n;
	}

	public void update(int index) {
		if(a[index]==1)
			return;
		a[index]=1;
		update(1, 0, n-1, index);
	}

	public void update(int i, int s, int e, int index) {

		if(s>e || index<s || e<index)
			return;

		if(s==e) {
			st[i]=1;
			return;
		}

		int mid=(s+e)/2;
		update(2*i, s, mid, index);
		update(2*i+1, mid+1, e, index);

		st[i]=st[2*i]+st[2*i+1];
	}

	public int query(int qs, int qe) {
		return query(1, 0, n-1, qs, qe);
	}

	public int query(int i, int s, int e, int qs, int qe) {

		if(s>e || qe<s || e<qs)
			return 0;

		if(qs<=s && e<=qe)
			return st[i];

		int mid=(s+e)/2;
		return query(2*i, s, mid, qs, qe) + query(2*i+1, mid+1, e, qs, qe);
	}
}