#include <bits/stdc++.h>
#pragma GCC optimize("-O3", "unroll-loops")
using namespace std;
template <typename T1, typename T2>
inline void chmin(T1& a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1& a, T2 b) {
  if (a < b) a = b;
}
const long long MOD = 1e9 + 7;
const long long MAX = 200010;
const double pi = acos(-1);
long long INF = 2e18;
const long long MAX_N = 1 << 19;
const long long MAX_V = 200010;
long long n, dat[2 * MAX_N - 1];
long long id[MAX_V];
long long add(long long x, long long y) { return x + y; }
void init(long long n_) {
  n = 1;
  while (n < n_) n *= 2;
  for (long long i = 0; i < 2 * n - 1; i++) dat[i] = 0;
}
void update(long long k, long long a) {
  k += n - 1;
  dat[k] = a;
  while (k > 0) {
    k = (k - 1) / 2;
    dat[k] = add(dat[k * 2 + 1], dat[k * 2 + 2]);
  }
}
long long query(long long a, long long b, long long k, long long l,
                long long r) {
  if (r <= a || b <= l) return 0;
  if (a <= l && r <= b)
    return dat[k];
  else {
    long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return add(vl, vr);
  }
}
long long X[200020], Y[200020];
vector<long long> G[200020];
void solve() {
  map<long long, long long> mpX, mpY;
  long long N;
  cin >> N;
  for (long long i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
    mpX[X[i]]++, mpY[Y[i]]++;
  }
  map<long long, long long> cmpX, cmpY;
  long long cx = 0, cy = 0;
  for (auto p : mpX) {
    cmpX[p.first] = cx;
    cx++;
  }
  for (auto p : mpY) {
    cmpY[p.first] = cy;
    cy++;
  }
  long long nx = mpX.size();
  init(nx);
  for (long long i = 0; i < N; i++) {
    long long x = cmpX[X[i]];
    long long y = cmpY[Y[i]];
    G[y].push_back(x);
  }
  long long ny = mpY.size();
  long long ans = 0;
  for (long long y = ny - 1; y >= 0; y--) {
    sort(G[y].begin(), G[y].end());
    ;
    long long pre = -1;
    long long sum = G[y].size();
    long long tmp = 0;
    for (auto x : G[y]) {
      long long cnt = query(pre + 1, x, 0, 0, n);
      tmp -= cnt * (cnt + 1) / 2;
      sum += cnt;
      pre = x;
      update(x, 1);
    }
    long long cnt = query(pre + 1, nx, 0, 0, n);
    tmp -= cnt * (cnt + 1) / 2;
    sum += cnt;
    tmp += sum * (sum + 1) / 2;
    ans += tmp;
  }
  cout << ans << '\n';
  ;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}
