#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, vector<int> > ps;
  set<int> xs;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    ps[y].push_back(x);
    xs.insert(x);
  }
  map<int, int> rk;
  const int INF = 1 << 30;
  for (int x : xs) {
    int i = rk.size();
    rk[x] = i + 1;
  }
  rk[INF] = xs.size() + 1;
  int bit[200100] = {};
  long long ans = 0;
  xs.clear();
  for (auto it = ps.rbegin(); it != ps.rend(); it++) {
    int y = it->first;
    sort(it->second.begin(), it->second.end());
    for (int i = 0; i < it->second.size(); i++) {
      int l = it->second[i],
          r = (i + 1 == it->second.size() ? INF : it->second[i + 1]);
      long long sum1 = 0, sum2 = 0;
      if (xs.find(l) == xs.end()) {
        xs.insert(l);
        for (int j = rk[l]; j <= rk.size() + 1; j += j & -j) bit[j]++;
      }
      for (int j = rk[l]; j > 0; j -= j & -j) sum1 += bit[j];
      for (int j = rk[r] - 1; j > 0; j -= j & -j) sum2 += bit[j];
      ans += sum1 * (sum2 - sum1 + 1);
    }
  }
  cout << ans << endl;
}
