#include <bits/stdc++.h>
using namespace std;
const double pai = acos(-1);
const double eps = 1e-10;
const long long mod = 1e9 + 7;
const int MXN = 1e6 + 5;
long long bit[MXN];
void update(int i, long long c, int nn) {
  while (i <= nn) {
    bit[i]++;
    i = i + (i & -i);
  }
}
long long query(int i) {
  long long re = 0;
  while (i > 0) {
    re += bit[i];
    i = i - (i & -i);
  }
  return re;
}
pair<int, int> po[MXN];
vector<int> lx, ly;
vector<int> v[MXN];
int ID(int x, int xx) {
  if (xx == 1) return lower_bound(lx.begin(), lx.end(), x) - lx.begin() + 1;
  return lower_bound(ly.begin(), ly.end(), x) - ly.begin() + 1;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &po[i].first, &po[i].second);
    lx.push_back(po[i].first);
    ly.push_back(po[i].second);
  }
  sort(lx.begin(), lx.end());
  sort(ly.begin(), ly.end());
  lx.erase(unique(lx.begin(), lx.end()), lx.end());
  ly.erase(unique(ly.begin(), ly.end()), ly.end());
  for (int i = 1; i <= n; i++) {
    int idx = ID(po[i].first, 1), idy = ID(po[i].second, 2);
    v[idy].push_back(idx);
  }
  int szx = (int)lx.size(), szy = (int)ly.size();
  long long ans = 0;
  for (int i = szy; i >= 1; i--) {
    sort(v[i].begin(), v[i].end());
    for (auto j : v[i]) {
      if (query(j) - query(j - 1) == 0) update(j, 1, szx);
    }
    int lll = 0;
    for (auto j : v[i]) {
      long long lg = query(j) - query(lll);
      long long rg = query(szx) - query(j - 1);
      ans = ans + lg * rg;
      lll = j;
    }
  }
  cout << ans << '\n';
  return 0;
}
