#include <bits/stdc++.h>
using namespace std;
int start = 1;
int N, k, n;
int a[800005];
long long cnt;
struct punct {
  int x, y;
} p[200005];
bool cmpy(punct _x, punct _y) {
  return _x.y < _y.y || _x.y == _y.y && _x.x > _y.x;
}
bool cmpx(punct _x, punct _y) { return _x.x < _y.x; }
int Query(int st, int dr) {
  int ans = 0;
  if (st & 1) ans = a[st++];
  if (!(dr & 1)) ans += a[dr--];
  if (st > dr) return ans;
  int aux = Query(st / 2, dr / 2);
  return ans + aux;
}
void adaug(int st, int mij, int dr) {
  int nrst = Query(st + start - 1, mij + start - 1);
  int nrdr = Query(mij + start - 1, dr + start - 1);
  cnt += (long long)nrst * (long long)nrdr;
}
void Update(int poz) {
  a[poz] = a[poz + poz] + a[poz + poz + 1];
  if (poz > 1) Update(poz / 2);
}
void adaug_aint(int poz) {
  a[start + poz - 1] = 1;
  Update((start + poz - 1) / 2);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i].x >> p[i].y;
  }
  int curent = 0;
  sort(p + 1, p + n + 1, cmpx);
  for (int i = 1; i <= n; ++i) {
    if (p[i].x != curent) {
      curent = p[i].x;
      p[i].x = ++k;
    } else
      p[i].x = k;
  }
  N = k;
  while (start < N) start <<= 1;
  sort(p + 1, p + n + 1, cmpy);
  k = 0;
  curent = 0;
  for (int i = 1; i <= n; ++i) {
    if (p[i].y != curent) {
      curent = p[i].y;
      p[i].y = ++k;
    } else
      p[i].y = k;
  }
  curent = 0;
  for (int i = n; i; --i) {
    int dr;
    if (p[i].y != curent) {
      curent = p[i].y;
      if (p[i - 1].y == curent)
        dr = p[i - 1].x - 1;
      else
        dr = N;
      adaug_aint(p[i].x);
      adaug(1, p[i].x, dr);
    } else {
      if (p[i - 1].y == curent)
        dr = p[i - 1].x - 1;
      else
        dr = N;
      adaug_aint(p[i].x);
      adaug(1, p[i].x, dr);
    }
  }
  cout << cnt;
  return 0;
}
