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.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni();
        long[][] p = new long[n][];
        TreeSet<Long> waste = new TreeSet<>();
        for(int i = 0; i< n; i++){
            p[i] = new long[]{nl(), nl()};
            waste.add(p[i][0]);
        }
        Arrays.sort(p, (long[] l1, long[] l2) -> {
            if(l1[1] != l2[1])return Long.compare(l2[1], l1[1]);
            return Long.compare(l1[0], l2[0]);
        });
        int c = 0;
        HashMap<Long, Integer> mp = new HashMap<>();
        for(long i:waste)mp.put(i, c++);
        int[] val = new int[n];
        for(int i = 0; i< n; i++)val[i] = mp.get(p[i][0]);
        
        
        SegTree t = new SegTree(c);
        long ans = 0;
        for(int i = 0; i< n; ){
            int j = i;
            long add = f(t.sum(0, val[i]-1));
            int prev = -1;
            while(j< n && p[i][1] == p[j][1]){
                if(prev != -1)add += f(t.sum(prev+1, val[j]-1));
                prev = val[j++];
                t.update(prev);
            }
            add += f(t.sum(prev+1, c-1));
            ans += f(t.sum(0, c-1))-add;
            i = j;
        }
        pn(ans);
    }
    class SegTree{
        int m = 1;
        int[] t;
        public SegTree(int n){
            while(m < n)m<<=1;
            t = new int[m<<1];
        }
        void update(int p){
            t[p+=m] = 1;
            for(p>>=1; p>0; p>>=1)t[p] = t[p<<1]+t[p<<1|1];
        }
        int sum(int l, int r){
            if(l > r)return 0;
            return sum(l, r, 0, m-1, 1);
        }
        int sum(int l, int r, int ll, int rr, int p){
            if(l == ll && r == rr)return t[p];
            int mid = (ll+rr)>>1;
            if(r <= mid)return sum(l, r, ll, mid, p<<1);
            else if(l > mid)return sum(l, r, mid+1, rr, p<<1|1);
            else return sum(l, mid, ll, mid, p<<1)+sum(mid+1, r, mid+1, rr, p<<1|1);
        }
    }
    long f(long f){
        return (f*f+f)/2;
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    long IINF = (long)1e18, mod = (long)998244353;
    final int INF = (int)1e9, MX = (int)2e5+5;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-6;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        hold(1 <= T && T <= 4);
        pre();for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

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

        String nextLine() throws Exception{
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }  
            return str;
        }
    }
}