#include <bits/stdc++.h>
using namespace std;
int tree[211111], tsize;
void add(int pos, int num) {
  for (int i = pos; i <= tsize; i += i & (-i)) tree[i] += num;
}
int getsum(int pos) {
  int res = 0;
  for (int i = pos; i; i -= i & (-i)) res += tree[i];
  return res;
}
int allx[211111], ally[211111], xsize, ysize, isused[211111];
pair<int, int> p[211111];
vector<int> v[211111];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n + 1; i++)
    scanf("%d%d", &p[i].first, &p[i].second), allx[++xsize] = p[i].first,
                                              ally[++ysize] = p[i].second;
  sort(allx + 1, allx + 1 + xsize), sort(ally + 1, ally + 1 + ysize);
  xsize = unique(allx + 1, allx + 1 + xsize) - allx - 1,
  ysize = unique(ally + 1, ally + 1 + ysize) - ally - 1;
  for (int i = 1; i < n + 1; i++) {
    int k1 = lower_bound(allx + 1, allx + 1 + xsize, p[i].first) - allx,
        k2 = lower_bound(ally + 1, ally + 1 + ysize, p[i].second) - ally;
    v[k2].push_back(k1);
  }
  tsize = xsize;
  long long res = 0;
  for (int i = ysize; i; i--) {
    sort(v[i].begin(), v[i].end());
    int bef = 0;
    for (int k : v[i]) {
      int k2 = getsum(k - 1);
      res += (k2 - bef + 1) * 1LL * bef;
      if (!isused[k]) isused[k] = 1, add(k, 1);
      bef = k2 + 1;
    }
    int k2 = getsum(tsize);
    res += (k2 - bef + 1) * 1LL * bef;
  }
  printf("%I64d\n", res);
}
