#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> a[200005];
vector<int> allX, allY, v[200005];
struct IntervalTree {
  int t[200005], cnt[200005 << 2];
  void upd(int l, int r, int id, int x, int val) {
    if (l == r) {
      t[l] += val;
      cnt[id] = (t[l] > 0);
      return;
    }
    if (x <= (r + l) / 2)
      upd(l, (r + l) / 2, id * 2, x, val);
    else
      upd((r + l) / 2 + 1, r, id * 2 + 1, x, val);
    cnt[id] = cnt[id * 2] + cnt[id * 2 + 1];
  }
  int get(int l, int r, int id, int x, int y) {
    if (x > y) return 0;
    if (l > y || r < x) return 0;
    if (l >= x && r <= y) return cnt[id];
    int a = get(l, (r + l) / 2, id * 2, x, y);
    int b = get((r + l) / 2 + 1, r, id * 2 + 1, x, y);
    return a + b;
  }
} t;
void setup() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = make_pair(x, y);
    allX.push_back(x);
    allY.push_back(y);
  }
  sort(allX.begin(), allX.end());
  allX.resize(unique(allX.begin(), allX.end()) - allX.begin());
  sort(allY.begin(), allY.end());
  allY.resize(unique(allY.begin(), allY.end()) - allY.begin());
  for (int i = 1; i <= n; i++) {
    a[i].first =
        lower_bound(allX.begin(), allX.end(), a[i].first) - allX.begin();
    a[i].second =
        lower_bound(allY.begin(), allY.end(), a[i].second) - allY.begin();
    v[a[i].second].push_back(a[i].first);
  }
}
void solve() {
  int szY = allY.size(), szX = allX.size();
  long long res = 0;
  for (int i = 0; i <= szY - 1; i++) sort(v[i].begin(), v[i].end());
  for (int i = 1; i <= n; i++) t.upd(0, szX - 1, 1, a[i].first, 1);
  for (int y = 0; y <= szY - 1; y++) {
    int sz = v[y].size();
    res += 1ll * t.get(0, szX - 1, 1, 0, v[y][0]) *
           t.get(0, szX - 1, 1, v[y][0], szX - 1);
    for (int i = 1; i <= sz - 1; i++) {
      res += 1ll * t.get(0, szX - 1, 1, v[y][i - 1] + 1, v[y][i]) *
             t.get(0, szX - 1, 1, v[y][i], szX - 1);
    }
    for (int i = 0; i <= sz - 1; i++) t.upd(0, szX - 1, 1, v[y][i], -1);
  }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("INP.TXT", "r")) {
    freopen("INP.TXT", "r", stdin);
    freopen("OUT.TXT", "w", stdout);
  }
  setup();
  solve();
}
