#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
pair<int, int> p[maxn];
vector<int> v1;
vector<int> v2;
set<int> v[maxn];
int getposx(int x) {
  return lower_bound(v1.begin(), v1.end(), x) - v1.begin() + 1;
}
int getposy(int y) {
  return lower_bound(v2.begin(), v2.end(), y) - v2.begin() + 1;
}
long long C[maxn];
void add(int x, int y) {
  while (x < maxn) {
    C[x] += y;
    x += (x) & (-x);
  }
}
long long getsum(int x) {
  long long sum = 0;
  while (x > 0) {
    sum += C[x];
    x -= (x) & (-x);
  }
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int x;
    int y;
    cin >> x >> y;
    p[i].first = x;
    p[i].second = y;
    v1.push_back(x);
    v2.push_back(y);
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  v1.erase(unique(v1.begin(), v1.end()), v1.end());
  v2.erase(unique(v2.begin(), v2.end()), v2.end());
  int pmaxx = 0;
  int pmaxy = 0;
  for (int i = 1; i <= N; i++) {
    p[i].first = getposx(p[i].first);
    pmaxx = max(pmaxx, p[i].first);
    p[i].second = getposy(p[i].second);
    pmaxy = max(pmaxy, p[i].second);
    v[p[i].second].insert(p[i].first);
  }
  long long ans = 0;
  set<int>::iterator it;
  for (int i = pmaxy; i >= 1; i--) {
    for (it = v[i].begin(); it != v[i].end(); it++) {
      int t = *it;
      if (getsum(t) - getsum(t - 1)) continue;
      add(t, 1);
    }
    int prev = 0;
    for (it = v[i].begin(); it != v[i].end(); it++) {
      int t = *it;
      ans +=
          (getsum(t - 1) - getsum(prev) + 1) * (getsum(pmaxx) - getsum(t) + 1);
      prev = t;
    }
  }
  cout << ans << endl;
  return 0;
}
