#include <bits/stdc++.h>
using namespace std;
struct fenwick {
  int n;
  vector<int> t;
  fenwick(int n = 0) : n(n) { t.assign(n, 0); }
  void incr(int i, int delta) {
    for (; i < n; i |= (i + 1)) t[i] += delta;
  }
  int sum(int r) {
    int s = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) s += t[r];
    return s;
  }
  int sum(int l, int r) { return sum(r) - sum(l - 1); }
};
int n;
vector<int> X, Y, x, y;
vector<vector<int> > g;
long long co(long long x) { return ((x + 1) * x) / 2; }
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  X.resize(n);
  Y.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> X[i] >> Y[i];
    x.push_back(X[i]);
    y.push_back(Y[i]);
  }
  sort(x.begin(), x.end());
  x.resize(unique(x.begin(), x.end()) - x.begin());
  sort(y.begin(), y.end());
  y.resize(unique(y.begin(), y.end()) - y.begin());
  for (int i = 0; i < n; ++i) {
    X[i] = lower_bound(x.begin(), x.end(), X[i]) - x.begin();
    Y[i] = lower_bound(y.begin(), y.end(), Y[i]) - y.begin();
  }
  g.resize(y.size());
  for (int i = 0; i < n; ++i) g[Y[i]].push_back(X[i]);
  long long res = 0;
  fenwick f(x.size());
  for (int i = g.size() - 1; i >= 0; --i) {
    vector<int> z = g[i];
    z.push_back(-1);
    z.push_back(x.size());
    sort(z.begin(), z.end());
    for (int j = 1; j < z.size(); ++j) res -= co(f.sum(z[j - 1] + 1, z[j] - 1));
    for (int j = 1; j < z.size() - 1; ++j)
      if (f.sum(z[j], z[j]) == 0) f.incr(z[j], 1);
    res += co(f.sum(0, x.size() - 1));
  }
  cout << res;
  return 0;
}
