#include <bits/stdc++.h>
using namespace std;
long long int LIM = 1e3 + 10;
vector<vector<long long int> > pre(LIM, vector<long long int>(LIM, 0));
long long int n, m;
long long int MAX = 2e5;
vector<long long int> tree(2 * (MAX + 10), 0);
long long int combine(long long int a, long long int b) { return a + b; }
void update(long long int pos, long long int value,
            vector<long long int> &tree) {
  pos += MAX - 1;
  tree[pos] = value;
  pos = pos / 2;
  while (pos >= 1) {
    tree[pos] = combine(tree[2 * pos], tree[2 * pos + 1]);
    pos = pos / 2;
  }
}
long long int query(long long int l, long long int r,
                    vector<long long int> &tree) {
  if (l > r) return 0;
  l += MAX - 1;
  r += MAX - 1;
  long long int ans = 0;
  while (l <= r) {
    if (l % 2 == 1) {
      ans = combine(ans, tree[l]);
      l++;
    }
    if (r % 2 == 0) {
      ans = combine(ans, tree[r]);
      r--;
    }
    l = l / 2;
    r = r / 2;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int> > arr(n + 1);
  set<long long int> x;
  set<long long int> y;
  for (long long int i = 1; i <= n; i++) {
    cin >> arr[i].first >> arr[i].second;
    x.insert(arr[i].first);
    y.insert(arr[i].second);
  }
  map<long long int, long long int> pos_x, pos_y;
  long long int counter = 1;
  for (auto it = x.begin(); it != x.end(); it++) pos_x[*it] = counter++;
  counter = 1;
  for (auto it = y.begin(); it != y.end(); it++) pos_y[*it] = counter++;
  long long int LIM = 2e5 + 10;
  vector<vector<long long int> > polls(LIM);
  for (long long int i = 1; i <= n; i++) {
    polls[pos_y[arr[i].second]].push_back(pos_x[arr[i].first]);
  }
  long long int ans = 0;
  for (long long int i = 1; i < LIM; i++)
    sort(polls[i].begin(), polls[i].end());
  for (long long int i = LIM - 1; i >= 1; i--) {
    for (long long int j = 0; j < polls[i].size(); j++) {
      long long int x = polls[i][j];
      update(x, 1, tree);
    }
    long long int x = query(1, MAX, tree);
    long long int temp = x + (x * (x - 1)) / 2;
    for (long long int j = 0; j < polls[i].size(); j++) {
      long long int j1 = j - 1;
      long long int y = 0;
      if (j1 >= 0) {
        y = query(polls[i][j1] + 1, polls[i][j] - 1, tree);
        temp -= y + (y * (y - 1)) / 2;
      } else {
        y = query(1, polls[i][j] - 1, tree);
        temp -= y + (y * (y - 1)) / 2;
      }
    }
    if (polls[i].size() > 0) {
      long long int y = query(polls[i].back() + 1, MAX, tree);
      temp -= y + (y * (y - 1)) / 2;
    }
    if (polls[i].size() > 0) ans += temp;
  }
  cout << ans << endl;
  return 0;
}
