#include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcount(s);
}
template <class T>
inline T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long n, a[200005], b[200005], c[200005], res;
pair<long long, long long> z[200005];
vector<long long> Y[200005];
bool ok[200005];
set<long long, greater<long long>> sy;
struct fenwick_tree {
  int n;
  vector<long long> fen;
  fenwick_tree(int _n) {
    this->n = _n;
    fen.resize(n + 5, 0);
  }
  void upd(int i, long long val) {
    while (i > 0) {
      fen[i] += val;
      i -= i & (-i);
    }
  }
  long long get(int i) {
    long long ans = 0;
    while (i <= n) {
      ans += fen[i];
      i += i & (-i);
    }
    return ans;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long i = 1, _b = n; i <= _b; i++) {
    cin >> z[i].first >> z[i].second;
    a[i] = z[i].first;
    b[i] = z[i].second;
  }
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  for (long long i = 1, _b = n; i <= _b; i++) {
    z[i].first = lower_bound(a + 1, a + n + 1, z[i].first) - a;
    z[i].second = lower_bound(b + 1, b + n + 1, z[i].second) - b;
    if (Y[z[i].second].size() == 0) Y[z[i].second].push_back(0);
    Y[z[i].second].push_back(z[i].first);
    sy.insert(z[i].second);
  }
  for (long long i = 1, _b = 200000; i <= _b; i++)
    sort(Y[i].begin(), Y[i].end());
  fenwick_tree F(200000);
  for (auto second : sy) {
    for (long long i = Y[second].size() - 1, _b = 0; i >= _b; i--) {
      if (i != 0 && ok[Y[second][i]] == false)
        F.upd(Y[second][i], 1), ok[Y[second][i]] = true;
      if (i + 1 < Y[second].size()) {
        res += (F.get(Y[second][i] + 1) - F.get(Y[second][i + 1] + 1)) *
               F.get(Y[second][i + 1]);
      }
    }
  }
  cout << res;
  return 0;
}
