#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1, c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f ^= 1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return f ? x : -x;
}
int n;
int x[200005], y[200005];
int vx[200005], cx;
int vy[200005], cy;
int lst[200005];
vector<int> xy[200005], yx[200005];
int getx(int x) { return lower_bound(vx, vx + cx, x) - vx; }
int gety(int y) { return lower_bound(vy, vy + cy, y) - vy; }
struct mtree {
  vector<int> node[800005];
  int siz;
  void ini() {
    for (siz = 1; siz <= cx; siz <<= 1)
      ;
    for (int i = 0; i < (int)(cx); ++i)
      node[i + siz].push_back(*max_element(xy[i].begin(), xy[i].end()));
    for (int i = siz - 1; i; --i) {
      node[i].resize(node[i + i].size() + node[i + i + 1].size());
      merge(node[i + i].begin(), node[i + i].end(), node[i + i + 1].begin(),
            node[i + i + 1].end(), node[i].begin());
    }
  }
  int qry(int l, int r, int x) {
    int cnt = 0;
    for (l += siz, r += siz; l < r; l >>= 1, r >>= 1) {
      if (l & 1)
        cnt += node[l].end() - lower_bound(node[l].begin(), node[l].end(), x),
            ++l;
      if (r & 1)
        --r, cnt +=
             node[r].end() - lower_bound(node[r].begin(), node[r].end(), x);
    }
    return cnt;
  }
} segt;
int main() {
  n = read();
  for (int i = 0; i < (int)(n); ++i) x[i] = read(), y[i] = read();
  for (int i = 0; i < (int)(n); ++i) vx[cx++] = x[i];
  for (int i = 0; i < (int)(n); ++i) vy[cy++] = y[i];
  sort(vx, vx + cx);
  sort(vy, vy + cy);
  cx = unique(vx, vx + cx) - vx;
  cy = unique(vy, vy + cy) - vy;
  for (int i = 0; i < (int)(n); ++i) xy[getx(x[i])].push_back(gety(y[i]));
  for (int i = 0; i < (int)(n); ++i) yx[gety(y[i])].push_back(getx(x[i]));
  long long ans = 0;
  segt.ini();
  for (int i = 0; i < (int)(cy); ++i) {
    sort(yx[i].begin(), yx[i].end());
    for (int j = 0; j < (int)(yx[i].size()); ++j) {
      int L = segt.qry(j ? yx[i][j - 1] + 1 : 0, yx[i][j] + 1, i);
      int R = segt.qry(yx[i][j], cx, i);
      ans += 1LL * L * R;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
