#include <bits/stdc++.h>
using namespace std;
const int N = 200010, LOG = 60;
int n;
vector<pair<int, int> > v;
vector<int> a, cur[N], b, c;
set<int> st;
set<int>::iterator it;
set<int>::iterator it2;
int cnt = 0, last;
int seg[4 * N];
int Idx;
int update(int s, int e, int idx) {
  if (s > Idx || e < Idx) return seg[idx];
  if (s == e) return seg[idx] = 1;
  return seg[idx] = update(s, ((s + e) >> 1), (idx << 1)) +
                    update(((s + e) >> 1) + 1, e, (idx << 1) + 1);
}
int l, r;
int getsum(int s, int e, int idx) {
  if (s > r || e < l) return 0;
  if (s >= l && e <= r) return seg[idx];
  return getsum(s, ((s + e) >> 1), (idx << 1)) +
         getsum(((s + e) >> 1) + 1, e, (idx << 1) + 1);
}
int main() {
  scanf("%d", &n);
  v.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &v[i].first, &v[i].second);
    a.push_back(v[i].second);
    c.push_back(v[i].first);
  }
  sort(a.begin(), a.end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
  sort(c.begin(), c.end());
  c.resize(unique(c.begin(), c.end()) - c.begin());
  for (int i = 0; i < n; i++) {
    cur[lower_bound(a.begin(), a.end(), v[i].second) - a.begin()].push_back(i);
  }
  long long ans = 0;
  int tmp1, tmp2;
  for (int i = (int)a.size() - 1; i >= 0; i--) {
    b.clear();
    for (int j = 0; j < (int)cur[i].size(); j++) {
      b.push_back(v[cur[i][j]].first);
      Idx = lower_bound(c.begin(), c.end(), v[cur[i][j]].first) - c.begin();
      update(0, (int)c.size() - 1, 1);
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < (int)b.size(); i++) {
      r = lower_bound(c.begin(), c.end(), b[i]) - c.begin();
      l = (i == 0 ? 0 : upper_bound(c.begin(), c.end(), b[i - 1]) - c.begin());
      if (r >= l)
        tmp1 = getsum(0, (int)c.size() - 1, 1);
      else
        tmp1 = 0;
      l = r;
      r = (int)c.size() - 1;
      tmp2 = getsum(0, (int)c.size() - 1, 1);
      ans += (long long)tmp1 * tmp2;
    }
  }
  cout << ans << endl;
  return 0;
}
