#include <bits/stdc++.h>
using namespace std;
int bit[200010];
int lb(int x) { return x & (-x); }
void add(int p, int x) {
  while (p < 200010) bit[p] += x, p += lb(p);
}
int query(int p) {
  int ans = 0;
  while (p) ans += bit[p], p -= lb(p);
  return ans;
}
int qlr(int l, int r) { return query(r) - query(l - 1); }
map<int, int> id, cnt;
map<int, vector<int>> v;
int num;
int main() {
  int i, n, x, y;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    v[y].push_back(x);
    cnt[x]++;
  }
  long long ans = 0;
  for (auto it : cnt) id[it.first] = ++num, add(num, 1);
  for (auto it : v) {
    sort((it).second.begin(), (it).second.end());
    int start = 1, ID;
    for (auto jt : it.second) {
      ID = id[jt];
      ans += (long long)qlr(start, ID) * qlr(ID, num);
      if (!--cnt[jt]) add(ID, -1);
      start = ID + 1;
    }
  }
  printf("%I64d", ans);
  return 0;
}
