#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 2000000000000000000LL;
const long double EPS = 1e-9;
const int N = 200000 + 7;
long long tr[4 * N];
void build() { memset(tr, 0, sizeof tr); }
void update(int at, int l, int r, int p, long long x) {
  if (l == r) {
    tr[at] = x;
    return;
  }
  int lc = at + at, rc = lc + 1, mid = (l + r) / 2;
  if (p <= mid)
    update(lc, l, mid, p, x);
  else
    update(rc, mid + 1, r, p, x);
  tr[at] = (tr[lc] + tr[rc]);
}
long long query(int at, int l, int r, int lo, int hi) {
  if (l > hi or r < lo) return 0;
  if (l >= lo and r <= hi) return tr[at];
  int lc = at + at, rc = lc + 1, mid = (l + r) / 2;
  return (query(lc, l, mid, lo, hi) + query(rc, mid + 1, r, lo, hi));
}
int x[N], y[N];
int n;
vector<int> g[N];
const int P = 200002;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> x[i] >> y[i];
  map<int, int> m;
  vector<int> v(x + 1, x + n + 1);
  sort((v).begin(), (v).end());
  v.erase(unique((v).begin(), (v).end()), v.end());
  for (int i = 0; i < (int)v.size(); ++i) m[v[i]] = i + 1;
  for (int i = 1; i <= n; ++i) x[i] = m[x[i]];
  m.clear();
  v = vector<int>(y + 1, y + n + 1);
  sort((v).begin(), (v).end());
  v.erase(unique((v).begin(), (v).end()), v.end());
  for (int i = 0; i < (int)v.size(); ++i) m[v[i]] = i + 1;
  for (int i = 1; i <= n; ++i) y[i] = m[y[i]];
  m.clear();
  for (int i = 1; i <= n; ++i) {
    g[y[i]].push_back(x[i]);
  }
  for (int i = 1; i <= P; ++i) sort((g[i]).begin(), (g[i]).end());
  build();
  long long res = 0;
  for (int i = P; i > 0; --i) {
    for (auto qq : g[i]) update(1, 1, P, qq, 1);
    long long cnt = query(1, 1, P, 1, P);
    res += ((cnt * (cnt - 1)) / 2);
    res += g[i].size();
    vector<int> v;
    v.push_back(0);
    for (auto qq : g[i]) {
      v.push_back(qq);
      update(1, 1, P, qq, 0);
    }
    v.push_back(P + 1);
    for (int i = 0; i + 1 < (int)v.size(); ++i) {
      int lo = v[i] + 1, hi = v[i + 1] - 1;
      cnt = query(1, 1, P, lo, hi);
      res -= ((cnt * (cnt - 1)) / 2);
    }
    for (auto qq : g[i]) update(1, 1, P, qq, 1);
  }
  cout << res << "\n";
  return 0;
}
