#include <bits/stdc++.h>
const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};
const int N = (int)2e5 + 228;
using namespace std;
struct Point {
  int x, y;
} a[N];
int n, b[N], t[N << 2];
bool cmp(Point l, Point r) { return l.y > r.y || (l.y == r.y && l.x < r.x); }
void upd(int id, int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = min(1, t[v] + 1);
    return;
  }
  int mid = (tl + tr) >> 1;
  if (id <= mid)
    upd(id, v << 1, tl, mid);
  else
    upd(id, v << 1 | 1, mid + 1, tr);
  t[v] = t[v << 1] + t[v << 1 | 1];
}
int get(int l, int r, int v, int tl, int tr) {
  if (tl > r || tr < l) return 0;
  if (tl >= l && tr <= r) {
    return t[v];
  }
  int mid = (tl + tr) >> 1;
  return get(l, r, v << 1, tl, mid) + get(l, r, v << 1 | 1, mid + 1, tr);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].x, &a[i].y);
    b[i] = a[i].x;
  }
  sort(b + 1, b + n + 1);
  int m = unique(b + 1, b + n + 1) - b - 1;
  for (int i = 1; i <= n; i++) {
    a[i].x = lower_bound(b + 1, b + m + 1, a[i].x) - b;
  }
  sort(a + 1, a + n + 1, &cmp);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int k1 = get(1, a[i].x - 1, 1, 1, m) + 1;
    int tr = m;
    if (i < n && a[i + 1].y == a[i].y) tr = a[i + 1].x - 1;
    int k2 = get(a[i].x + 1, tr, 1, 1, m) + 1;
    ans += 1ll * k1 * k2;
    upd(a[i].x, 1, 1, m);
  }
  cout << ans << endl;
  return 0;
}
