#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200005;
int ft[N];
void add(int x, int val) {
  for (; x < N; x += x & -x) ft[x] += val;
}
int sum(int x) {
  int ans = 0;
  for (; x > 0; x -= x & -x) ans += ft[x];
  return ans;
}
int sum(int i, int j) { return sum(j) - sum(i - 1); }
int n, x[N], y[N], id[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d %d", x + i, y + i), id[i] = i;
  {
    set<int> s;
    map<int, int> go;
    for (int i = 0; i < n; i++) s.insert(x[i]);
    int p = 1;
    for (int w : s) go[w] = p++;
    for (int i = 0; i < n; i++) x[i] = go[x[i]];
  }
  for (int i = 0; i < n; i++) {
    ;
  }
  sort(id, id + n, [](int i, int j) {
    if (y[i] != y[j]) return y[i] > y[j];
    return x[i] < x[j];
  });
  ll ans = 0;
  for (int q = 0; q < n; q++) {
    int w = q;
    while (w + 1 < n and y[id[q]] == y[id[w + 1]]) w++;
    for (int k = q; k <= w; k++) {
      int i = id[k];
      if (sum(x[i], x[i]) == 0) add(x[i], 1);
    }
    int last = 0;
    for (int k = q; k <= w; k++) {
      int i = id[k];
      ;
      ans += 1LL * sum(last + 1, x[i]) * sum(x[i], N - 1);
      last = x[i];
    }
    q = w;
  }
  printf("%lld\n", ans);
}
