#include <bits/stdc++.h>
using namespace std;
struct node {
  long long x, y;
} p[200015];
long long n;
set<long long> S;
vector<long long> vx, vy;
bool cmp(node a, node b) {
  if (a.y != b.y)
    return a.y > b.y;
  else
    return a.x < b.x;
}
namespace BIT {
long long d[200015 * 3];
void add(long long p) {
  p++;
  if (S.find(p) != S.end()) return;
  S.insert(p);
  for (; p <= 200015 * 2; p += ((p) & (-p))) d[p]++;
}
long long query(long long p) {
  long long res = 0;
  p++;
  for (; p; p -= ((p) & (-p))) res += d[p];
  return res;
}
long long query(long long l, long long r) {
  if (l > r) return 0;
  return query(r) - query(l - 1);
}
}  // namespace BIT
using namespace BIT;
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++)
    scanf("%lld%lld", &p[i].x, &p[i].y), vx.push_back(p[i].x),
        vy.push_back(p[i].y);
  sort(vx.begin(), vx.end());
  vx.erase(unique(vx.begin(), vx.end()), vx.end());
  sort(vy.begin(), vy.end());
  vy.erase(unique(vy.begin(), vy.end()), vy.end());
  for (long long i = 1; i <= n; i++)
    p[i].x = lower_bound(vx.begin(), vx.end(), p[i].x) - vx.begin() + 1,
    p[i].y = lower_bound(vy.begin(), vy.end(), p[i].y) - vy.begin() + 1;
  sort(p + 1, p + n + 1, cmp);
  for (long long i = 1; i <= (long long)vy.size(); i++) vy[i - 1] = i;
  reverse(vy.begin(), vy.end());
  long long cur = 0, ans = 0;
  for (auto Y : vy) {
    long long las = 0;
    while (cur + 1 <= n && p[cur + 1].y >= Y) {
      cur++;
      add(p[cur].x);
      long long sum = query(las + 1, p[cur].x - 1);
      las = p[cur].x;
      ans -= sum * (sum + 1) / 2;
    }
    long long ss = query(las + 1, 200015 * 2);
    ans -= ss * (ss + 1) / 2;
    long long sum = query(200015 * 2);
    ans += sum * (sum + 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}
