#include <bits/stdc++.h>
using ll = long long;
using namespace std;
void upd(int k, int x, vector<int>& tree, int n) {
  if (k == 0) {
    return;
  }
  while (k <= n) {
    tree[k] += x;
    k += (k & -k);
  }
}
int sum(int k, vector<int>& tree, int n) {
  int s = 0;
  while (k >= 1) {
    s += tree[k];
    k -= (k & -k);
  }
  return s;
}
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  map<int, vector<int>> mp;
  map<int, int> mpy, mpx;
  vector<int> vx, vy;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    mp[y].push_back(x);
    if (mpx[x] == 0) {
      vx.push_back(x);
      mpx[x] = 1;
    }
    if (mpy[y] == 0) {
      vy.push_back(y);
      mpy[y] = 1;
    }
  }
  for (auto y : mp) {
    sort(mp[y.first].begin(), mp[y.first].end());
  }
  int m = vx.size();
  sort(vx.begin(), vx.end());
  map<int, int> indx;
  for (int i = 0; i < m; i++) {
    indx[vx[i]] = i;
  }
  vector<int> treex(m + 1);
  sort(vy.begin(), vy.end());
  reverse(vy.begin(), vy.end());
  int k = vy.size();
  ll ans = 0;
  map<int, int> visx;
  for (int i = 0; i < k; i++) {
    int a = mp[vy[i]].size();
    int prevl = 0, prevr = 0, lastl = 0, sub = 0;
    for (int g = 0; g < a; g++) {
      if (visx[mp[vy[i]][g]]) {
        sub += 1;
      }
    }
    for (int j = 0; j < a; j++) {
      int x = mp[vy[i]][j];
      int ind = indx[x];
      if (visx[x]) {
        sub -= 1;
      }
      if (visx[x] == 0) {
        upd(ind + 1, 1, treex, m);
        visx[x] = 1;
      }
      int left = sum(ind, treex, m);
      int right = sum(m, treex, m);
      int indl = j, indr = a - j - 1 - sub;
      int r = right - (left + 1);
      ll add = (left + 1 - indl - lastl) * 1LL * (r + 1 + indr);
      lastl = (left - indl);
      ans += add;
    }
  }
  cout << ans << endl;
}
