#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} pt[400005];
bool cmp(node a, node b) { return a.y == b.y ? a.x < b.x : a.y > b.y; }
int n, Ha[400005], C[400005], vis[400005], tot;
long long ans;
void Add(int x) {
  for (int i = x; i <= tot; i += (i & -i)) ++C[i];
}
int Query(int x) {
  int ret = 0;
  if (!x) return 0;
  for (int i = x; i; i ^= (i & -i)) ret += C[i];
  return ret;
}
void Process(int l, int r) {
  int pre = 0;
  for (int i = l; i <= r; i++)
    if (!vis[pt[i].x]) vis[pt[i].x] = 1, Add(pt[i].x);
  for (int i = l; i <= r; i++) {
    ans += 1ll * (Query(pt[i].x - 1) - Query(pre) + 1) *
           (Query(tot) - Query(pt[i].x) + 1);
    pre = pt[i].x;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &pt[i].x, &pt[i].y), Ha[++tot] = pt[i].x;
  sort(Ha + 1, Ha + tot + 1);
  tot = unique(Ha + 1, Ha + tot + 1) - Ha - 1;
  for (int i = 1; i <= n; i++)
    pt[i].x = lower_bound(Ha + 1, Ha + tot + 1, pt[i].x) - Ha;
  sort(pt + 1, pt + n + 1, cmp);
  for (int i = 1; i <= n;) {
    int l = i, r = i;
    while (r <= n && pt[r].y == pt[l].y) r++;
    Process(l, --r), i = r + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
