#include <bits/stdc++.h>
using namespace std;
int tree[1000005], n;
int next(int n) {
  int cnt = 0;
  if (n && !(n & (n - 1))) {
    return n;
  }
  while (n) {
    n >>= 1;
    cnt++;
  }
  return (1 << cnt);
}
void update(int p, int value) {
  p += n;
  for (tree[p] = value; p > 1; p >>= 1) {
    tree[p >> 1] = tree[p] + tree[p ^ 1];
  }
}
int query(int l, int r) {
  int res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) {
      res += (tree[l++]);
    }
    if (r & 1) {
      res += (tree[--r]);
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  n = 200000;
  int x, y;
  vector<pair<int, int> > v;
  map<int, set<int> > ms;
  map<int, int> compress;
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    v.push_back({x, y});
    compress[x] = 0;
  }
  auto tt = compress.begin();
  int cnt = 0;
  while (tt != compress.end()) {
    compress[tt->first] = cnt++;
    tt++;
  }
  for (int i = 0; i <= m - 1; i++) {
    y = v[i].second;
    x = v[i].first;
    ms[-y].insert(compress[x]);
  }
  n = next(n);
  long long int ans = 0;
  auto it = ms.begin();
  while (it != ms.end()) {
    auto it2 = (it->second).begin();
    while (it2 != (it->second).end()) {
      update(*it2, 1);
      it2++;
    }
    auto it3 = (it->second).begin();
    int pre = 0;
    while (it3 != (it->second).end()) {
      int cur = *it3;
      long long int one = (long long int)query(pre, cur + 1);
      long long int two = (long long int)query(cur, n);
      ans += (one * two);
      pre = cur + 1;
      it3++;
    }
    it++;
  }
  cout << ans << '\n';
}
