#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n;
int a[maxn], c[maxn];
struct qnode {
  int x, y;
} q[maxn];
bool cmp(qnode q1, qnode q2) {
  return q1.y == q2.y ? q1.x < q2.x : q1.y > q2.y;
}
int lowbit(int x) { return x & (-x); }
void update(int k, int x) {
  for (int i = k; i <= n; i += lowbit(i)) c[i] += x;
}
int query(int k) {
  int res = 0;
  for (int i = k; i; i -= lowbit(i)) res += c[i];
  return res;
}
int main() {
  int cnt = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &q[i].x, &q[i].y);
    a[++cnt] = q[i].x;
  }
  sort(q + 1, q + n + 1, cmp);
  sort(a + 1, a + cnt + 1);
  cnt = unique(a + 1, a + cnt + 1) - a - 1;
  for (int i = 1; i <= n; i++) {
    q[i].x = lower_bound(a + 1, a + cnt + 1, q[i].x) - a;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int p = i;
    while (p < n && q[p + 1].y == q[p].y) p++;
    for (int j = i; j <= p; j++) {
      int tmp = query(q[j].x) - query(q[j].x - 1);
      if (!tmp) update(q[j].x, 1);
      ans += query(q[j].x);
      if (j < p)
        ans +=
            (long long)(query(q[j + 1].x - 1) - query(q[j].x)) * query(q[j].x);
      else
        ans += (long long)(query(cnt) - query(q[j].x)) * query(q[j].x);
    }
    i = p;
  }
  printf("%lld\n", ans);
  return 0;
}
