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.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
 
 
public class q5 {
	
    
    
	
 
	public static void main(String[] args) throws IOException {
		
	Reader.init(System.in);
	PrintWriter out=new PrintWriter(System.out);
	int n=Reader.nextInt();
	ArrayList<Integer> arr=new ArrayList<Integer>();
	NoD[] p=new NoD[n+1];
	for(int i=0;i<n;i++) {
		int a=Reader.nextInt(),b=Reader.nextInt();
		p[i]=new NoD(a,b);
		arr.add(a);
	}
	p[n]=new NoD(0,0);
	Collections.sort(arr);
	int v=1;
	HashMap<Integer,Integer> hm=new HashMap<Integer,Integer>();
	hm.put(0, 0);
	for(int i=0;i<n;i++) {
		int c=arr.get(i);
		if(!hm.containsKey(c)) hm.put(c, v++);
	}
	Arrays.sort(p,new Comparator<NoD>() {
		public int compare(NoD a, NoD b) {
			if(b.y==a.y) return b.x-a.x;
			return b.y-a.y;
		}
	});
	Seg tree=new Seg(n+1);
	long ans=0;
	int y=p[0].y;
	for(int i=0;i<n;i++) {
		NoD c=p[i];
		int l=hm.get(p[i].x);
			long r=tree.query(0, 0, n, l+1, n);
			int lf=hm.get(p[i+1].x);
			if(p[i+1].y!=p[i].y) lf=0;
			long ll=tree.query(0, 0, n, lf+1, l-1);
			ans+=ll+r+ll*r+1;
		tree.update(0, 0, n, l);
	}
	out.print(ans);
	out.flush();
		
	}
}

class NoD{
	int x,y;
	NoD(int a,int b){
		x=a;y=b;
	}
}
 
class Seg{
	int[] st;
	
	Seg(int n){
		st=new int[4*n];
	}
	
	long query(int index,int left, int right, int ql, int qh) {
		if(ql<=left && right<=qh) return st[index];
		if(ql>right || qh <left) return 0;
		int mid=(left+right)/2;
		return query(2*index+1,left,mid,ql,qh)+ query(2*index+2,mid+1,right,ql,qh);
	}
	
	
	
	void update(int index, int left, int right, int pos) {
		if(left==right) {
			st[index]=1;
		}
		else {
			int mid=(left+right)/2;
			if(pos<=mid) {
				update(2*index+1,left,mid,pos);
			}
			else update(2*index+2,mid+1,right,pos);
			st[index]=st[2*index+1]+st[2*index+2];
		}
	}
}
 
 
 
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    /** call this method to initialize reader for InputStream */
    static void init() throws IOException {
    	 reader = new BufferedReader(
                 new FileReader("pattern.in") );
    tokenizer = new StringTokenizer("");
    }
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String nextLine() throws IOException{
    	return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}