#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int x[N], y[N], ord[N], use[N];
int n, m = 0;
int bit[N];
void add(int x) {
  for (int i = x; i <= m; i += (i & -i)) ++bit[i];
}
int query(int x) {
  int ret = 0;
  for (int i = x; i > 0; i ^= (i & -i)) ret += bit[i];
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
  map<int, int> dict;
  for (int i = 1; i <= n; i++) dict[x[i]] = 0;
  for (auto &w : dict) w.second = ++m;
  for (int i = 1; i <= n; i++) x[i] = dict[x[i]];
  for (int i = 1; i <= n; i++) ord[i] = i;
  sort(ord + 1, ord + n + 1, [&](int i, int j) -> bool {
    return (y[i] == y[j] ? x[i] < x[j] : y[i] > y[j]);
  });
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    int j = i;
    while (j + 1 <= n && y[ord[i]] == y[ord[j + 1]]) ++j;
    for (int k = i; k <= j; k++)
      if (!use[x[ord[k]]]) add(x[ord[k]]), use[x[ord[k]]] = 1;
    long long w = query(m);
    res += w * (w + 1) / 2;
    if (x[ord[i]] > 1) {
      w = query(x[ord[i]] - 1);
      res -= w * (w + 1) / 2;
    }
    for (int k = i + 1; k <= j; k++) {
      w = query(x[ord[k]] - 1) - query(x[ord[k - 1]]);
      res -= w * (w + 1) / 2;
    }
    if (x[ord[j]] < m) {
      w = query(m) - query(x[ord[j]]);
      res -= w * (w + 1) / 2;
    }
    i = j;
  }
  cout << res << endl;
  return 0;
}
