#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const double PI = acos(-1);
template <class A, class B>
std::ostream& operator<<(std::ostream& st, const std::pair<A, B> p) {
  st << "(" << p.first << ", " << p.second << ")";
  return st;
}
using namespace std;
const int MAXN = 2 * 100 * 1000 + 10, MAXST = 1 << 20;
std::pair<int, int> P[MAXN];
int n;
int BIT[MAXN];
void add(int p, int v) {
  for (; p; p ^= ((p) & (-(p)))) BIT[p] += v;
}
int get(int p) {
  int ret = 0;
  for (; p < MAXN; p += ((p) & (-(p)))) ret += BIT[p];
  return ret;
}
int main() {
  scanf("%d", &n);
  map<int, int> M;
  for (int i = 0; i < (n); i++) {
    scanf("%d %d", &P[i].second, &P[i].first);
    P[i].first *= -1;
    M[P[i].second];
  }
  sort(P, P + n);
  for (int i = 0; i < (n); i++) P[i].first *= -1;
  int m = 0;
  for (auto& p : M) p.second = ++m;
  for (int i = 0; i < (n); i++) P[i].second = M[P[i].second];
  std::vector<int> Xs;
  long long ans = 0;
  set<int> S;
  for (int i = 0; i < n;) {
    int y = P[i].first;
    int j = i;
    Xs.clear();
    while (j < n && P[j].first == y) {
      Xs.push_back(P[j].second);
      j++;
    }
    for (int x : Xs)
      if (!S.count(x)) add(x, 1), S.insert(x);
    int prv = 0;
    for (int x : Xs) {
      long long left = get(prv + 1) - get(x + 1);
      long long right = get(x);
      ans += left * right;
      prv = x;
    }
    i = j;
  }
  cout << ans << endl;
  return 0;
}
