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>
#include <bits/stdc++.h>
using namespace std;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
long long MOD = 1e9 + 7;
template <typename T>
struct BIT {
  vector<T> data;
  BIT(int size) { data.assign(++size, 0); }
  T sum(int k) {
    T ret = 0;
    for (++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }
  void add(int k, T x) {
    for (++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
int main() {
  int n = in();
  vector<pair<int, int> > v;
  for (long long i = 0; i < n; i++) {
    int x = in(), y = in();
    v.push_back({-y, x});
  }
  set<int> s;
  map<int, int> mp;
  vector<int> a;
  for (long long i = 0; i < n; i++) {
    a.push_back(v[i].second);
  }
  sort(begin(v), end(v));
  sort(begin(a), end(a));
  a.erase(unique(begin(a), end(a)), a.end());
  for (long long i = 1; i <= a.size(); ++i) {
    mp[a[i - 1]] = i;
  }
  for (long long i = 0; i < n; i++) {
    v[i].second = mp[v[i].second];
  }
  int pos = 0;
  long long ans = 0;
  BIT<long long> BIT(250000);
  while (pos < n) {
    int next = pos;
    vector<int> t;
    t.push_back(0);
    while (next < n && v[pos].first == v[next].first) {
      t.push_back(v[next].second);
      next++;
    }
    t.push_back(250000);
    sort(begin(t), end(t));
    for (long long i = 0; i < t.size() - 1; i++) {
      long long T = BIT.sum(t[i + 1] - 1) - BIT.sum(t[i]);
      T = max(T, 0ll);
      ans -= T * (T + 1) / 2;
    }
    for (long long i = 1; i <= t.size() - 2; ++i) {
      if (BIT.sum(t[i]) - BIT.sum(t[i] - 1) == 0) {
        BIT.add(t[i], 1);
      }
    }
    long long S = BIT.sum(250000);
    ans += S * (S + 1) / (long long)2;
    pos = next;
  }
  cout << ans;
}
