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>
// package CodeForces;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.TreeMap;
import java.util.TreeSet;

public class Round573Div1_D {

	public static int[] st;
	
	public static void update (int start, int end, int index, int idx) {
		if (idx < start || idx > end) {
			return;
		}
		if (start == end) {
			st[index] = 1;
			return;
		}
		int mid = (start + end) >> 1;
		update (start, mid, index<<1, idx);
		update (mid + 1, end, index<<1|1, idx);
		st[index] = st[index<<1] + st[index<<1|1];
	}
	
	public static int query (int start, int end, int index, int l, int r) {
		if (r < l || r < start || l > end) {
			return 0;
		}
		if (l <= start && end <= r) {
			return st[index];
		}
		int mid = (start + end) >> 1;
		return query (start, mid, index<<1, l, r) + query (mid + 1, end, index<<1|1, l, r);
	}
	
	public static void solve() {
		int n = s.nextInt();
		Point[] points = new Point[n];
		TreeMap<Integer, ArrayList<Point>> ys = new TreeMap<Integer, ArrayList<Point>>();
		TreeSet<Integer> xs = new TreeSet<Integer>();
		for (int i = 0; i < n; i++) {
			points[i] = new Point(s.nextInt(), s.nextInt());
			if (ys.containsKey(-points[i].y)) {
				ys.get(-points[i].y).add(points[i]);
			} else {
				ArrayList<Point> list = new ArrayList<Point>();
				list.add(points[i]);
				ys.put(-points[i].y, list);
			}
			xs.add(points[i].x);
		}
		for (ArrayList<Point> list : ys.values()) {
			Collections.sort(list);
		}
		int ptr = 0;
		TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
		for (Integer x : xs) {
			map.put(x, ptr++);
		}
		int m = map.size();
		st = new int[4 * m + 1];
		// Going over all the horizontal lines
		long ans = 0L;
		for (Integer y : ys.keySet()) {
			ArrayList<Point> curr = ys.get(y);
			for (int i = 0; i < curr.size(); i++) {
				update(0, m - 1, 1, map.get(curr.get(i).x));
			}
			int final_index = m - 1;
			int last_index = 0;
			for (int i = 0; i < curr.size(); i++) {
				int current_index = map.get(curr.get(i).x);
				ans = ans +(1L * query(0, m - 1, 1, last_index, current_index) * query (0, m - 1, 1, current_index, final_index));
				last_index = current_index + 1;
			}
		}
		out.println(ans);
	}
	
	public static class Point implements Comparable<Point>{
		int x;
		int y;
		
		public Point (int x, int y) {
			this.x = x;
			this.y = y;
		}
		
		public int compareTo(Point x) {
			return this.x - x.x;
		}
	}

	public static void main(String[] args) {
		new Thread(null, null, "Thread", 1 << 27) {
			public void run() {
				try {
					out = new PrintWriter(new BufferedOutputStream(System.out));
					s = new FastReader(System.in);
					solve();
					out.close();
				} catch (Exception e) {
					e.printStackTrace();
					System.exit(1);
				}
			}
		}.start();
	}

	public static PrintWriter out;
	public static FastReader s;

	public static class FastReader {

		private InputStream stream;
		private byte[] buf = new byte[4096];
		private int curChar, snumChars;

		public FastReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (snumChars == -1) {
				throw new InputMismatchException();
			}
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException E) {
					throw new InputMismatchException();
				}
			}
			if (snumChars <= 0) {
				return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int number = 0;
			do {
				number *= 10;
				number += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			long sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long number = 0;
			do {
				number *= 10L;
				number += (long) (c - '0');
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

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

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

		public String next() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndofLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndofLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	
}
