#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAXN = 2 * 2 * 1e5 + 7;
int cum[MAXN + 1];
int mark[MAXN + 1];
void upd(int i) {
  if (mark[i] > 0) return;
  mark[i] = 1;
  while (i <= MAXN) {
    cum[i] += 1;
    i += i & -i;
  }
}
int get(int i) {
  int ans = 0;
  while (i) {
    ans += cum[i];
    i -= i & -i;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> xx, yy;
  map<int, int> val;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    xx.push_back(x);
    yy.push_back(y);
    val[x] = 0;
    val[y] = 0;
  }
  int idx = 1;
  for (auto e : val) {
    val[e.first] = idx++;
  }
  vector<pair<int, int>> p;
  for (int i = 0; i < n; ++i) {
    p.push_back({val[yy[i]], val[xx[i]]});
  }
  sort(p.begin(), p.end());
  long long ans = 0;
  while (!p.empty()) {
    int cury = p.back().first;
    vector<int> xs;
    while (!p.empty() && p.back().first == cury) {
      xs.push_back(p.back().second);
      p.pop_back();
    }
    reverse(xs.begin(), xs.end());
    xs.push_back(MAXN);
    int L = 1;
    long long corr = 0;
    for (int x : xs) {
      long long n = get(x - 1) - get(L - 1);
      corr += n * (n - 1) / 2 + n;
      L = x + 1;
    }
    for (int x : xs) {
      if (x == MAXN) break;
      upd(x);
    }
    long long n = get(MAXN);
    ans += n * (n - 1) / 2 + n - corr;
  }
  cout << ans << endl;
  return 0;
}
