#include <bits/stdc++.h>
using namespace std;
template <typename T>
T Max(T x, T y) {
  return x > y ? x : y;
}
template <typename T>
T Min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
T Fabs(T x) {
  return x < 0 ? -x : x;
}
long long ans;
int n;
struct node {
  int x, y, lsx, lsy;
  bool operator<(const node &rhs) const {
    if (lsy != rhs.lsy) return lsy > rhs.lsy;
    return lsx < rhs.lsx;
  }
};
node a[200005];
struct TREE {
  long long sum;
  int l, r;
};
TREE tre[800005];
bool cmp1(node x, node y) { return x.x < y.x; }
bool cmp2(node x, node y) { return x.y < y.y; }
void build(int x, int l, int r) {
  if (l == r) {
    tre[x].l = l, tre[x].r = r;
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  tre[x].l = tre[x << 1].l, tre[x].r = tre[x << 1 | 1].r;
}
void update(int x, int l, int r) {
  if (tre[x].l > r || tre[x].r < l) return;
  if (tre[x].l == l && tre[x].r == r) {
    tre[x].sum = 1;
    return;
  }
  update(x << 1, l, r);
  update(x << 1 | 1, l, r);
  tre[x].sum = tre[x << 1].sum + tre[x << 1 | 1].sum;
}
long long query(int x, int l, int r) {
  long long ret = 0;
  if (tre[x].l > r || tre[x].r < l) return 0;
  if (tre[x].l >= l && tre[x].r <= r) return tre[x].sum;
  ret += query(x << 1, l, r) + query(x << 1 | 1, l, r);
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d %d", &a[i].x, &a[i].y);
  sort(a + 1, a + 1 + n, cmp1);
  for (int i = 1; i <= n; i++) {
    if (a[i].x == a[i - 1].x)
      a[i].lsx = a[i - 1].lsx;
    else
      a[i].lsx = a[i - 1].lsx + 1;
  }
  sort(a + 1, a + 1 + n, cmp2);
  for (int i = 1; i <= n; i++) {
    if (a[i].y == a[i - 1].y)
      a[i].lsy = a[i - 1].lsy;
    else
      a[i].lsy = a[i - 1].lsy + 1;
  }
  sort(a + 1, a + 1 + n);
  build(1, 1, n);
  update(1, a[1].lsx, a[1].lsx);
  for (int i = 2; i <= n + 1; i++) {
    if (a[i].lsy == a[i - 1].lsy)
      update(1, a[i].lsx, a[i].lsx);
    else {
      int s = i - 1, last = 0;
      while (a[s - 1].lsy == a[i - 1].lsy) s--;
      for (int j = s; j <= i - 1; j++) {
        ans += query(1, a[j].lsx, n) * query(1, a[last].lsx + 1, a[j].lsx);
        last = j;
      }
      update(1, a[i].lsx, a[i].lsx);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
