#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long re = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) re = (re << 1) + (re << 3) + ch - '0', ch = getchar();
  return re * flag;
}
long long n, mx, m, ans;
namespace seg {
long long seg[1000010];
inline void update(long long num) {
  seg[num] = seg[num << 1] + seg[num << 1 | 1];
}
inline void add(long long l, long long r, long long num, long long pos) {
  if (l == r) {
    seg[num] = 1;
    return;
  }
  long long mid = (l + r) >> 1;
  if (mid >= pos)
    add(l, mid, num << 1, pos);
  else
    add(mid + 1, r, num << 1 | 1, pos);
  update(num);
}
inline long long query(long long l, long long r, long long ql, long long qr,
                       long long num) {
  if (l >= ql && r <= qr) return seg[num];
  long long mid = (l + r) >> 1, re = 0;
  if (mid >= ql) re += query(l, mid, ql, qr, num << 1);
  if (mid < qr) re += query(mid + 1, r, ql, qr, num << 1 | 1);
  return re;
}
}  // namespace seg
struct node {
  long long x, y;
} a[200010];
inline bool cmp1(const node &a, const node &b) { return a.x < b.x; }
inline bool cmp2(const node &a, const node &b) {
  if (a.y != b.y) return a.y < b.y;
  return a.x > b.x;
}
int main() {
  n = read();
  long long i, j, k;
  for (i = 1; i <= n; i++) a[i].x = read(), a[i].y = read();
  sort(a + 1, a + n + 1, cmp1);
  for (i = 1; i <= n; i = j + 1) {
    m++;
    j = i;
    while (j < n && a[j + 1].x == a[i].x) a[++j].x = m;
    a[i].x = m;
  }
  sort(a + 1, a + n + 1, cmp2);
  for (i = 1; i <= n; i = j + 1) {
    mx++;
    j = i;
    while (j < n && a[j + 1].y == a[i].y) a[++j].y = mx;
    a[i].y = mx;
  }
  reverse(a + 1, a + n + 1);
  for (i = 1; i <= n; i = j + 1) {
    j = i;
    while (j < n && a[j + 1].y == a[i].y) j++;
    for (k = i; k <= j; k++) {
      seg::add(1, m, 1, a[k].x);
    }
    for (k = i; k <= j; k++) {
      ans += seg::query(1, m, ((k == i) ? 1 : a[k - 1].x + 1), a[k].x, 1) *
             seg::query(1, m, a[k].x, m, 1);
    }
  }
  cout << ans << '\n';
}
