#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
const int N = 4e5 + 10;
const long long mod = 1e9 + 7;
const bool debug = false;
pair<int, int> po[N];
vector<int> vc;
int tot[N];
struct BITstree {
  int node[N];
  void init(int n) {
    for (int i = 1; i <= n; ++i) node[i] = 0;
  }
  int sum(int x) {
    int ret = 0;
    for (; x; x -= (x & (-x))) ret += node[x];
    return ret;
  }
  void up(int x, int n, int d) {
    for (; x <= n; x += (x & (-x))) node[x] += d;
  }
} bit;
bool cmp(pair<int, int> x, pair<int, int> y) {
  if (x.second == y.second) return x.first < y.first;
  return x.second < y.second;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &po[i].first, &po[i].second);
    vc.push_back(po[i].first);
  }
  sort(vc.begin(), vc.end());
  vc.erase(unique(vc.begin(), vc.end()), vc.end());
  int si = vc.size();
  bit.init(si);
  for (int i = 1; i <= n; ++i) {
    int id = lower_bound(vc.begin(), vc.end(), po[i].first) - vc.begin() + 1;
    tot[id]++;
    if (tot[id] == 1) bit.up(id, si, 1);
  }
  sort(po + 1, po + n + 1, cmp);
  long long ans = 0;
  for (int i = 1, j; i <= n;) {
    j = i;
    while (po[j].second == po[i].second && j <= n) j++;
    for (int k = i, pre = 0; k < j; ++k) {
      int id = lower_bound(vc.begin(), vc.end(), po[k].first) - vc.begin() + 1;
      int l = bit.sum(id) - bit.sum(pre), r = bit.sum(si) - bit.sum(id) + 1;
      ans += l * 1ll * r;
      pre = id;
      tot[id]--;
      if (tot[id] == 0) bit.up(id, si, -1);
    }
    i = j;
  }
  printf("%lld\n", ans);
  return 0;
}
