#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int lowbit(int x) { return x & -x; }
int bit[N + 2];
int sum(int pos) {
  int res = 0;
  while (pos) res += bit[pos], pos -= lowbit(pos);
  return res;
}
void upd(int pos, int x) {
  while (pos <= N) {
    bit[pos] += x;
    pos += lowbit(pos);
  }
}
struct point {
  int x, y;
} p[200005];
bool cmp(point a, point b) { return a.y > b.y || (a.y == b.y && a.x < b.x); }
int n, vis[N];
vector<int> v;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i].x >> p[i].y;
    v.push_back(p[i].x);
  }
  v.erase(unique(v.begin(), v.end()), v.end());
  sort(v.begin(), v.end());
  sort(p + 1, p + 1 + n, cmp);
  for (int i = 1; i <= n; i++)
    p[i].x = lower_bound(v.begin(), v.end(), p[i].x) - v.begin() + 1;
  long long ans = 0;
  for (int l = 1, r; l <= n; l = r) {
    r = l;
    vector<int> g;
    while (p[r].y == p[l].y) g.push_back(p[r].x), r++;
    g.push_back(200001);
    for (int i = l; i < r; i++)
      if (!vis[p[i].x]) upd(p[i].x, 1), vis[p[i].x] = 1;
    for (int i = 0; i < g.size() - 1; i++) {
      long long f = sum(g[i]), s = sum(g[i + 1] - 1);
      ans += f * (s - f + 1);
    }
  }
  cout << ans << endl;
}
