#include <bits/stdc++.h>
using namespace std;
const long long maxn = 200010;
const long long INF = 2147483647;
struct node {
  long long x, y;
} a[maxn];
node r[maxn];
bool cmpy(node x, node y) {
  if (x.y == y.y) return x.x < y.x;
  return x.y > y.y;
}
long long n, ix[maxn], iy[maxn], totx, toty, cnt[maxn], tot, res;
bool vis[maxn];
long long lowbit(long long x) { return x & (-x); }
void update(long long x) {
  while (x <= n) {
    cnt[x]++;
    x += lowbit(x);
  }
  return;
}
long long qry(long long x) {
  long long tem = 0;
  while (x) {
    tem += cnt[x];
    x -= lowbit(x);
  }
  return tem;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].x >> a[i].y;
    ix[i] = a[i].x;
    iy[i] = a[i].y;
  }
  sort(ix + 1, ix + n + 1);
  sort(iy + 1, iy + n + 1);
  totx = unique(ix + 1, ix + n + 1) - ix - 1;
  toty = unique(iy + 1, iy + n + 1) - iy - 1;
  for (int i = 1; i <= n; i++) {
    a[i].x = lower_bound(ix + 1, ix + totx + 1, a[i].x) - ix;
    a[i].y = lower_bound(iy + 1, iy + toty + 1, a[i].y) - iy;
  }
  sort(a + 1, a + n + 1, cmpy);
  for (int i = 1; i <= n; i++) {
    if (i < n && a[i].y == a[i + 1].y) {
      if (!vis[a[i].x]) {
        update(a[i].x);
        vis[a[i].x] = 1;
      }
      continue;
    }
    if (!vis[a[i].x]) {
      update(a[i].x);
      vis[a[i].x] = 1;
    }
    long long pos = i;
    while (a[pos - 1].y == a[pos].y && pos > 1) pos--;
    long long item = 0;
    for (int j = pos; j <= i; j++) {
      res += 1ll * (qry(n) - qry(a[j].x - 1)) * (qry(a[j].x) - qry(item));
      item = a[j].x;
    }
  }
  cout << res;
  return 0;
}
