#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct node {
  long long x, y;
};
set<long long> sx, sy;
map<long long, long long> mx, my;
map<long long, set<long long> > ma;
vector<node> ve;
int t[N];
inline int lowbit(int x) { return x & (-x); }
void add(int x, int k) {
  for (int i = x; i < N; i += lowbit(i)) {
    t[i] += k;
  }
}
int sum(int x) {
  int ans = 0;
  for (int i = x; i; i -= lowbit(i)) {
    ans += t[i];
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  long long x, y;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    ve.push_back(node{x, y});
    sx.insert(x);
    sy.insert(y);
  }
  int xx = 0;
  for (auto p : sx) {
    mx[p] = ++xx;
  }
  int yy = 0;
  for (auto p : sy) {
    my[p] = ++yy;
  }
  for (auto p : ve) {
    ma[my[p.y]].insert(mx[p.x]);
  }
  long long ans = 0;
  for (int i = yy; i >= 1; i--) {
    if (i == yy) {
      ans = (long long)(ma[i].size() + 1) * ma[i].size() / 2;
      for (auto p : ma[i]) {
        add(p, 1);
      }
      continue;
    }
    for (auto p : ma[i]) {
      if (sum(p) - sum(p - 1) == 0) {
        add(p, 1);
      }
    }
    int res = 0;
    for (auto p : ma[i]) {
      auto p1 = sum(p - 1) - sum(res);
      auto p2 = sum(N - 1) - sum(p);
      ans = ans + (long long)(p1 + 1) * (p2 + 1);
      res = p;
    }
  }
  cout << ans << endl;
}
