#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
struct node {
  int x, y;
  bool operator<(const node &p) const { return y == p.y ? x < p.x : y > p.y; }
} a[maxn];
int x[maxn], xn, v[maxn], c[maxn];
int num[maxn], ll, rr;
int n, numx, upp, vxx;
long long anss = 0;
int sum(int x) {
  int ans = 0;
  while (x) {
    ans = ans + c[x];
    x = x - (x & -x);
  }
  return ans;
}
void add(int x) {
  if (v[x])
    return;
  else {
    v[x] = 1;
    while (x <= upp) {
      c[x] = c[x] + 1;
      x = x + (x & -x);
    }
  }
}
int ssum(int x, int y) { return sum(y) - sum(x - 1); }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].x >> a[i].y;
    x[i] = a[i].x;
    v[i] = 0;
  }
  sort(x + 1, x + 1 + n);
  int numx = unique(x + 1, x + 1 + n) - (x + 1);
  for (int i = 1; i <= n; i++) {
    a[i].x = lower_bound(x + 1, x + 1 + numx, a[i].x) - x;
  }
  sort(a + 1, a + 1 + n);
  anss = 0;
  upp = numx + 1;
  int pre = 1, cur = 1;
  while (pre <= n) {
    vxx = 0;
    while (a[pre].y == a[cur].y) {
      vxx++;
      add(a[cur].x);
      num[vxx] = a[cur].x;
      cur++;
    }
    vxx++;
    num[vxx] = upp;
    for (int i = 1; i <= vxx - 1; i++) {
      ll = ssum(1, num[i] - 1);
      rr = ssum(num[i] + 1, num[i + 1] - 1);
      anss = anss + 1LL * (ll + 1) * (rr + 1);
    }
    pre = cur;
  }
  cout << anss << endl;
  return 0;
}
