#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];
long long _sum;
const int MAXM = 200005;
bool cntx[MAXM + 5];
int bit[MAXM + 5];
int upper;
inline int sum(int x) {
  int res = 0;
  while (x) {
    res = res + bit[x];
    x -= x & -x;
  }
  return res;
}
inline void update(int x) {
  if (cntx[x])
    return;
  else {
    cntx[x] = true;
    while (x <= upper) {
      bit[x] += 1;
      x += x & -x;
    }
  }
}
inline int range_sum(int x, int y) { return sum(y) - sum(x - 1); }
int *vx = x, vxtop;
int main() {
  while (~scanf("%d", &n)) {
    memset(cntx, false, sizeof(cntx));
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &p[i].x, &p[i].y);
      x[i] = p[i].x;
    }
    sort(x + 1, x + 1 + n);
    int xn = unique(x + 1, x + 1 + n) - (x + 1);
    for (int i = 1; i <= n; i++) {
      p[i].x = lower_bound(x + 1, x + 1 + xn, p[i].x) - x;
    }
    sort(p + 1, p + 1 + n);
    _sum = 0;
    upper = xn + 1;
    int beg = 1, cur = 1;
    while (beg <= n) {
      vxtop = 0;
      while (p[cur].y == p[beg].y) {
        update(p[cur].x);
        vx[++vxtop] = p[cur].x;
        cur++;
      }
      vx[++vxtop] = xn + 1;
      for (int i = 1; i <= vxtop - 1; i++) {
        int cntl = range_sum(1, vx[i] - 1);
        int cntr = range_sum(vx[i] + 1, vx[i + 1] - 1);
        _sum += 1ll * (cntl + 1) * (cntr + 1);
      }
      beg = cur;
    }
    printf("%lld\n", _sum);
  }
}
