#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 9;
const long long int mod = 1e9 + 696969;
const long long int MOD = 1e9 + 696969;
const long long INF = 1e18 + 3;
map<int, vector<int> > M;
int n;
map<int, int> skal;
vector<int> tp;
inline long long int f(long long int x) { return x * (x - 1) / 2 + x; }
const int maxn = 200100;
int A[maxn], B[maxn];
long long int dr[maxn];
int jest[maxn];
inline void add(int p, long long int v) {
  for (; p < maxn; p += p & (-p)) dr[p] += v;
}
inline long long int get(int p) {
  long long int res = 0;
  for (; p > 0; p -= p & (-p)) res += dr[p];
  return res;
}
inline long long int query(int a, int b) {
  if (a > b) return 0;
  return get(b) - get(a - 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = (1); i <= (n); ++i) {
    int x, y;
    cin >> x >> y;
    A[i] = x;
    B[i] = y;
    tp.push_back(x);
  }
  sort(tp.begin(), tp.end());
  int SKAL = 0;
  skal[tp[0]] = ++SKAL;
  for (int i = 1; i < (int)tp.size(); ++i)
    if (tp[i] != tp[i - 1]) skal[tp[i]] = ++SKAL;
  for (int i = (1); i <= (n); ++i) {
    A[i] = skal[A[i]];
    M[-B[i]].push_back(A[i]);
  }
  long long int result = 0;
  for (auto &u : M) {
    vector<int> v = u.second;
    sort(v.begin(), v.end());
    for (auto elem : v) {
      if (!jest[elem]) jest[elem] = 1, add(elem, 1);
    }
    int sz = (int)v.size();
    result += f(query(1, n));
    result -= f(query(1, v[0] - 1));
    result -= f(query(v[sz - 1] + 1, n));
    for (int i = 1; i < sz; ++i) result -= f(query(v[i - 1] + 1, v[i] - 1));
  }
  cout << result;
}
