#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e8;
long long kk(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return res;
}
long long n, k, a, b, ans, y;
struct node {
  int x, y;
  bool operator<(const node &p) const { return y == p.y ? x < p.x : y > p.y; }
} zb[200005];
const int N = 1000100;
int x[N];
bool vis[N];
string ch;
int c[N], up;
void upda(int x) {
  for (int i = x; i <= up; i += ((i) & -(i))) c[i] += 1;
}
int gets(int x) {
  int ans = 0;
  for (int i = x; i; i -= ((i) & -(i))) ans += c[i];
  return ans;
}
int sum(int x, int y) { return gets(y) - gets(x - 1); }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> zb[i].x >> zb[i].y;
    x[i] = zb[i].x;
  }
  sort(x + 1, x + 1 + n);
  int cnt = unique(x + 1, x + 1 + n) - (x + 1);
  up = cnt + 1;
  for (int i = 1; i <= n; i++) {
    zb[i].x = lower_bound(x + 1, x + cnt + 1, zb[i].x) - x;
  }
  sort(zb + 1, zb + 1 + n);
  int now = 1, next = 1;
  while (now <= n) {
    k = 0;
    while (zb[now].y == zb[next].y) {
      if (!vis[zb[next].x]) upda(zb[next].x);
      vis[zb[next].x] = 1;
      x[++k] = zb[next].x;
      next++;
    }
    x[++k] = up + 1;
    for (int i = 1; i < k; i++) {
      int t1 = sum(1, x[i] - 1);
      int t2 = sum(x[i] + 1, x[i + 1] - 1);
      ans += 1ll * (t1 + 1) * (t2 + 1);
    }
    now = next;
  }
  cout << ans;
}
