#include <bits/stdc++.h>
using namespace std;
set<int> S;
map<int, int> M;
struct node {
  int x, y;
} A[222222];
bool operator<(const node x, const node y) {
  if (x.y != y.y) {
    return x.y > y.y;
  } else {
    return x.x < y.x;
  }
}
int T[222222];
void add(int x) {
  while (x <= 200000) {
    T[x]++;
    x += ((x) & (-(x)));
  }
}
int query(int x) {
  int res = 0;
  while (x) {
    res += T[x];
    x -= ((x) & (-(x)));
  }
  return res;
}
int N;
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d%d", &A[i].x, &A[i].y);
    M[A[i].x] = 0;
  }
  int cnt = 0;
  for (map<int, int>::iterator i = M.begin(); i != M.end(); i++) {
    (i->second) = ++cnt;
  }
  sort(A + 1, A + N + 1);
  A[0].x = -1;
  A[0].y = -1;
  A[N + 1].x = -1;
  A[N + 1].y = -1;
  long long ANS = 0;
  for (int i = 1; i <= N; i++) {
    int l = M[A[i].x];
    if (S.find(A[i].x) == S.end()) {
      S.insert(A[i].x);
      add(l);
    }
    if (A[i + 1].y != A[i].y) {
      ANS += (long long)(query(l)) * (query(200000) - query(l) + 1);
    } else {
      ANS += (long long)(query(l)) * (query(M[A[i + 1].x] - 1) - query(l) + 1);
    }
  }
  printf("%lld", ANS);
  return 0;
}
