#include <bits/stdc++.h>
long long inp() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  long long sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum;
}
struct BIT {
  long long f[200010];
  void modify(long long x, long long c) {
    for (long long i = x; i <= 200000; i += ((i) & (-i))) f[i] += c;
  }
  long long query(long long x) {
    long long sum = 0;
    for (long long i = x; i; i -= ((i) & (-i))) sum += f[i];
    return sum;
  }
} t;
std::pair<long long, long long> s[200010];
std::map<long long, bool> used;
long long a[200010];
std::vector<long long> vec;
bool cmp(std::pair<long long, long long> a, std::pair<long long, long long> b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
signed main() {
  long long n = inp();
  for (long long i = 1; i <= n; i++) {
    s[i].first = inp();
    s[i].second = inp();
    a[i] = s[i].first;
    std::swap(s[i].first, s[i].second);
  }
  std::sort(a + 1, a + n + 1);
  long long cc = std::unique(a + 1, a + n + 1) - a - 1;
  for (long long i = 1; i <= n; i++)
    s[i].second = std::lower_bound(a + 1, a + cc + 1, s[i].second) - a;
  std::sort(s + 1, s + n + 1, cmp);
  long long cnt = 0;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    vec.clear();
    long long rb = i;
    while (s[i].first == s[rb].first && rb <= n) {
      if (!used[s[rb].second]) {
        cnt++;
        used[s[rb].second] = true;
        t.modify(s[rb].second, 1);
      }
      vec.push_back(s[rb].second);
      rb++;
    }
    ans += ((cnt * cnt + cnt) >> 1);
    long long last = 0;
    for (long long i = 0; i < vec.size(); i++) {
      long long c2 = t.query(vec[i] - 1) - last;
      ans -= (c2 * c2 + c2) >> 1;
      last = t.query(vec[i]);
    }
    long long c2 = t.query(200000) - last;
    ans -= (c2 * c2 + c2) >> 1;
    rb--;
    i = rb;
  }
  printf("%lld\n", ans);
}
