#include <bits/stdc++.h>
using namespace std;
int x[200010], y[200010];
int B[200010];
int fx[200010], fy[200010];
vector<int> adj[200010];
int cnt[200010];
void update(int u, int x) {
  while (u < 200010) {
    B[u] += x;
    u += u & (-u);
  }
}
int calc(int u) {
  int s = 0;
  while (u > 0) {
    s += B[u];
    u -= u & (-u);
  }
  return s;
}
int main() {
  int n;
  scanf("%d", &n);
  int nx = 0, ny = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    fx[++nx] = x[i];
    fy[++ny] = y[i];
  }
  sort(fx + 1, fx + nx + 1);
  sort(fy + 1, fy + ny + 1);
  nx = unique(fx + 1, fx + nx + 1) - fx - 1;
  ny = unique(fy + 1, fy + ny + 1) - fy - 1;
  for (int i = 1; i <= n; i++) {
    int id = lower_bound(fy + 1, fy + ny + 1, y[i]) - fy;
    int jd = lower_bound(fx + 1, fx + nx + 1, x[i]) - fx;
    adj[id].push_back(jd);
    if (!cnt[jd]) update(jd, 1);
    cnt[jd]++;
  }
  for (int i = 1; i <= ny; i++) sort(adj[i].begin(), adj[i].end());
  long long ans = 0;
  for (int i = 1; i <= ny; i++) {
    int sz = adj[i].size();
    int st = adj[i][0], ed = adj[i][sz - 1];
    int tot = calc(200010 - 1);
    ans += 1LL * (tot + 1) * tot / 2;
    tot -= calc(ed);
    ans -= 1LL * (tot + 1) * tot / 2;
    tot = calc(st - 1);
    ans -= 1LL * (tot + 1) * tot / 2;
    if (sz > 1) {
      for (int j = 0; j < sz - 1; j++) {
        int p = adj[i][j], q = adj[i][j + 1];
        int ct = calc(q - 1) - calc(p);
        ans -= 1LL * ct * (ct + 1) / 2;
      }
    }
    for (int j = 0; j < sz; j++) {
      int x = adj[i][j];
      cnt[x]--;
      if (!cnt[x]) update(x, -1);
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
