#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, x[maxn], y[maxn], dis[maxn], cx, cy;
vector<int> vec[maxn];
long long ans;
int c[maxn];
void modify(int x) {
  for (; x <= cx; x += (x & -x)) c[x]++;
}
int _query(int x) {
  int ret = 0;
  for (; x; x -= (x & -x)) ret += c[x];
  return ret;
}
int query(int l, int r) { return _query(r) - _query(l - 1); }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
  for (int i = 1; i <= n; i++) dis[i] = x[i];
  sort(dis + 1, dis + 1 + n);
  cx = unique(dis + 1, dis + 1 + n) - dis - 1;
  for (int i = 1; i <= n; i++)
    x[i] = lower_bound(dis + 1, dis + 1 + cx, x[i]) - dis;
  for (int i = 1; i <= n; i++) dis[i] = y[i];
  sort(dis + 1, dis + 1 + n);
  cy = unique(dis + 1, dis + 1 + n) - dis - 1;
  for (int i = 1; i <= n; i++)
    y[i] = lower_bound(dis + 1, dis + 1 + cy, y[i]) - dis;
  for (int i = 1; i <= n; i++) vec[y[i]].push_back(x[i]);
  for (int i = cy; i; i--) {
    sort(vec[i].begin(), vec[i].end());
    for (int j : vec[i])
      if (!query(j, j)) modify(j);
    ans += 1ll * query(1, vec[i][0]) * query(vec[i][0], cx);
    for (int j = 1; j < vec[i].size(); j++)
      ans += 1ll * query(vec[i][j - 1] + 1, vec[i][j]) * query(vec[i][j], cx);
  }
  cout << ans << endl;
  return 0;
}
