#include <bits/stdc++.h>
using namespace std;
int n;
struct Point {
  int x, y;
  bool operator<(const Point &p) const { return y == p.y ? x < p.x : y > p.y; }
} p[200005];
int x[200005];
int y[200005];
long long sum;
const int MAXM = 200000;
int st[(MAXM << 2) + 5];
inline void push_up(int o) { st[o] = st[o << 1] + st[o << 1 | 1]; }
void build(int o, int l, int r) {
  if (l == r) {
    st[o] = 0;
  } else {
    int m = (l + r) >> 1;
    build(o << 1, l, m);
    build(o << 1 | 1, m + 1, r);
    push_up(o);
  }
}
void update(int o, int l, int r, int x, int v) {
  if (l == r) {
    st[o] = v;
    return;
  } else {
    int m = (l + r) >> 1;
    if (x <= m)
      update(o << 1, l, m, x, v);
    else if (x >= m + 1)
      update(o << 1 | 1, m + 1, r, x, v);
    push_up(o);
  }
}
int query(int o, int l, int r, int a, int b) {
  if (b < a)
    return 0;
  else if (a <= l && r <= b) {
    return st[o];
  } else {
    int m = (l + r) >> 1;
    int ans = 0;
    if (a <= m) ans = query(o << 1, l, m, a, b);
    if (b >= m + 1) ans += query(o << 1 | 1, m + 1, r, a, b);
    return ans;
  }
}
int vx[200005], vxtop;
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &p[i].x, &p[i].y);
      x[i] = p[i].x;
      y[i] = p[i].y;
    }
    sort(x + 1, x + 1 + n);
    int xn = unique(x + 1, x + 1 + n) - (x + 1);
    sort(y + 1, y + 1 + n);
    int yn = unique(y + 1, y + 1 + n) - (y + 1);
    for (int i = 1; i <= n; i++) {
      p[i].x = lower_bound(x + 1, x + 1 + xn, p[i].x) - x;
      p[i].y = lower_bound(y + 1, y + 1 + yn, p[i].y) - y;
    }
    sort(p + 1, p + 1 + n);
    sum = 0;
    build(1, 1, xn + 1);
    int beg = 1, cur = 1;
    while (beg <= n) {
      vxtop = 0;
      while (p[cur].y == p[beg].y) {
        update(1, 1, xn + 1, p[cur].x, 1);
        vx[++vxtop] = p[cur].x;
        cur++;
      }
      vx[++vxtop] = xn + 1;
      for (int i = 1; i <= vxtop - 1; i++) {
        int cntl = query(1, 1, xn + 1, 1, vx[i] - 1);
        int cntr = query(1, 1, xn + 1, vx[i] + 1, vx[i + 1] - 1);
        sum += 1ll * (cntl + 1) * (cntr + 1);
      }
      beg = cur;
    }
    printf("%lld\n", sum);
  }
}
