#include <bits/stdc++.h>
using namespace std;
void in(int& x) {
  int f = 1;
  x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
void out(int a) {
  if (a < 0) {
    putchar('-');
    a = -a;
  }
  if (a >= 10) out(a / 10);
  putchar(a % 10 + '0');
}
void outl(long long int a) {
  if (a < 0) {
    putchar('-');
    a = -a;
  }
  if (a >= 10) outl(a / 10);
  putchar(a % 10 + '0');
}
const int inf = 0x3f3f3f3f, N = 2e5 + 10, maxs = 2e5 + 5;
struct node {
  int x, y;
  friend bool operator<(const node& n1, const node& n2) {
    if (n1.y != n2.y)
      return n1.y > n2.y;
    else
      return n1.x < n2.x;
  }
} no[N], nn;
int heng[N], a[N];
int lowbit(int x) { return x & (-x); }
void add(int x, int t) {
  while (x < maxs) {
    a[x] += t;
    x += lowbit(x);
  }
}
long long int cha(int x) {
  long long int ans = 0;
  while (x) {
    ans += a[x];
    x -= lowbit(x);
  }
  return ans;
}
bool vis[N];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    memset(a, 0, sizeof(a));
    memset(vis, 0, sizeof(vis));
    map<int, int> m;
    for (int i = 1; i <= n; i++) {
      in(nn.x);
      in(nn.y);
      no[i] = nn;
      heng[i] = nn.x;
    }
    sort(heng + 1, heng + n + 1);
    int num = unique(heng + 1, heng + n + 1) - heng - 1;
    for (int i = 1; i <= num; i++) m[heng[i]] = i;
    num++;
    add(maxs - 1, 1);
    sort(no + 1, no + n + 1);
    no[n + 1].y = inf;
    int qq = 0;
    long long int ans = 0;
    for (int i = 1; i <= n; i++) {
      int x = m[no[i].x];
      if (!vis[x]) {
        add(x, 1);
        vis[x] = 1;
      }
      if (no[i].y != no[i + 1].y) {
        if (!qq) {
          long long int l = cha(x);
          long long int r = cha(maxs - 1) - l;
          ans += l * r;
        } else {
          for (int j = qq; j <= i; j++) {
            int ak = m[no[j].x];
            if (j == qq) {
              long long int l = cha(ak);
              long long int r = cha(maxs - 1) - l;
              ans += l * r;
            } else {
              long long int l = cha(ak) - cha(m[no[j - 1].x]);
              long long int r = cha(maxs - 1) - cha(ak);
              ans += l * r;
            }
          }
        }
        qq = 0;
      } else if (qq == 0)
        qq = i;
    }
    outl(ans);
    printf("\n");
  }
  return 0;
}
