#include <bits/stdc++.h>
using namespace std;
long long n, tot;
struct dat {
  long long x, y;
} V[200005];
struct node {
  node *st, *dr;
  long long uniq, tot;
}* tata = new node();
map<long long, vector<long long> > M;
void add(node* act, long long l, long long r, long long x) {
  if (l == r) {
    act->uniq = 1;
    act->tot++;
    return;
  }
  long long mijl = (l + r) / 2;
  if (act->st == nullptr) {
    act->st = new node();
    act->st->uniq = 0;
    act->st->tot = 0;
  }
  if (act->dr == nullptr) {
    act->dr = new node();
    act->dr->uniq = 0;
    act->dr->tot = 0;
  }
  if (x <= mijl)
    add(act->st, l, mijl, x);
  else
    add(act->dr, mijl + 1, r, x);
  act->uniq = act->st->uniq + act->dr->uniq;
}
long long query(node* act, long long l, long long r, long long ql,
                long long qr) {
  if (ql <= l && r <= qr) {
    return act->uniq;
  }
  long long mijl = (l + r) / 2;
  if (qr <= mijl) {
    if (act->st == nullptr) return 0;
    return query(act->st, l, mijl, ql, qr);
  }
  if (mijl + 1 <= ql) {
    if (act->dr == nullptr) return 0;
    return query(act->dr, mijl + 1, r, ql, qr);
  }
  long long left = 0, right = 0;
  if (act->st != nullptr) left = query(act->st, l, mijl, ql, mijl);
  if (act->dr != nullptr) right = query(act->dr, mijl + 1, r, mijl + 1, qr);
  return left + right;
}
void rm(node* act, long long l, long long r, long long x) {
  if (l == r) {
    act->tot--;
    if (act->tot == 0) act->uniq = 0;
    return;
  }
  long long mijl = (l + r) / 2;
  if (x <= mijl)
    rm(act->st, l, mijl, x);
  else
    rm(act->dr, mijl + 1, r, x);
  act->uniq = act->st->uniq + act->dr->uniq;
}
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> V[i].x >> V[i].y;
    M[V[i].y].push_back(V[i].x);
    add(tata, 1 - 1, 1000000000 + 1, V[i].x);
  }
  for (auto m : M) {
    vector<long long>& X = m.second;
    long long sum = 0;
    long long sq = 0;
    sort(X.begin(), X.end());
    for (long long i = 1; i < X.size(); i++) {
      if (X[i - 1] + 1 == X[i]) {
        sum++;
        sq++;
        continue;
      }
      long long nr =
          query(tata, 1 - 1, 1000000000 + 1, X[i - 1] + 1, X[i] - 1) + 1;
      sum += nr;
      sq += nr * nr;
    }
    long long nr = query(tata, 1 - 1, 1000000000 + 1, 0, X[0] - 1) + 1;
    sum += nr;
    sq += nr * nr;
    nr = query(tata, 1 - 1, 1000000000 + 1, X[X.size() - 1] + 1,
               1000000000 + 1) +
         1;
    sum += nr;
    sq += nr * nr;
    tot += (sum * sum - sq) / 2;
    for (auto i : X) rm(tata, 1 - 1, 1000000000 + 1, i);
  }
  cout << tot;
  return 0;
}
