#include <bits/stdc++.h>
using namespace std;
int discretize(vector<int> &ori) {
  vector<pair<int, int>> ele;
  for (int i = 0; i < ori.size(); i++) {
    ele.push_back(make_pair(ori[i], i));
  }
  sort(ele.begin(), ele.end());
  int idx = 0, pre = ele[0].first - 1;
  for (auto e : ele) {
    if (e.first > pre) {
      idx++;
    }
    ori[e.second] = idx;
    pre = e.first;
  }
  return idx + 1;
}
inline long long calc(long long x) { return x * (x - 1) / 2 + x; }
void add(vector<int> &c, int x) {
  while (x < c.size()) {
    c[x] += 1;
    x += x & -x;
  }
}
int get(vector<int> &c, int x) {
  int res = 0;
  while (x) {
    res += c[x];
    x -= x & -x;
  }
  return res;
}
int query(vector<int> &c, int l, int r) {
  if (l > r) {
    return 0;
  }
  if (l) {
    l = get(c, l - 1);
  }
  r = get(c, r);
  return r - l;
}
int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  int rng = discretize(x);
  vector<pair<int, int>> p;
  for (int i = 0; i < n; i++) {
    p.push_back(make_pair(y[i], x[i]));
  }
  sort(p.begin(), p.end(), greater<pair<int, int>>());
  vector<int> c(rng + 1, 0);
  int tot = 0;
  long long ans = 0;
  for (int i = 0, j = 0; i < n; i = j) {
    while (p[j].first == p[i].first) {
      if (!query(c, p[j].second, p[j].second)) {
        add(c, p[j].second);
        tot++;
      }
      j++;
    }
    ans += calc(tot);
    int pre = rng;
    for (int k = i; k < j; k++) {
      ans -= calc(query(c, p[k].second + 1, pre));
      pre = p[k].second - 1;
    }
    ans -= calc(query(c, 0, pre));
  }
  cout << ans << endl;
  return 0;
}
