#include <bits/stdc++.h>
using namespace std;
void ga(int N, int *A) {
  for (int i(0); i < N; i++) scanf("%d", A + i);
}
void rnm(int *A, int N) {
  static pair<int, int> B[200996];
  int L = 0;
  for (int i(0); i < N; i++) B[i] = {A[i], i};
  sort(B, B + N);
  for (int i(0); i < N; i++)
    A[B[i].second] = L += i && B[i].first ^ B[i - 1].first;
}
struct FW {
  int t[200996], S;
  void clr(int s) {
    (memset(t, 0, sizeof(t)));
    S = s;
  }
  void inc(int i, int d) {
    for (; i < S; i |= i + 1) t[i] += d;
  }
  int sum(int i) {
    int s(0);
    while (~i) s += t[i], i &= i + 1, --i;
    return s;
  }
  int gt(int l, int r) {
    if (l > r) return 0;
    return sum(r) - sum(l - 1);
  }
} F;
long long S;
int X[200996], Y[200996], N, C[200996], H[200996], x, y, l, r, w;
bool cp(int a, int b) { return Y[a] ^ Y[b] ? Y[a] < Y[b] : X[a] < X[b]; }
int main(void) {
  scanf("%d", &N), iota(H, H + N, 0);
  for (int i(0); i < N; i++) scanf("%d%d", X + i, Y + i);
  rnm(X, N), rnm(Y, N), F.clr(N + 666), sort(H, H + N, cp), w = -1, l = 0,
                                                            r = N + 2;
  for (int i(0); i < N; i++)
    if (!C[X[i]]++) F.inc(X[i], 1);
  for (int i(0); i < N; i++) {
    x = X[H[i]], y = Y[H[i]];
    if (y ^ w) l = 0, r = N + 2, w = y;
    long long a = F.gt(l, x - 1) + 1, b = F.gt(x + 1, r) + 1;
    S += a * b, l = x + 1;
    if (!--C[x]) F.inc(x, -1);
  }
  printf("%lld\n", S);
  return 0;
}
