#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
  return x;
}
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
const double eps = 1e-9;
int n;
int cnt1, cnt2;
struct P {
  int x, y;
} p[maxn];
int f[maxn];
bool cmp1(P a, P b) {
  if (a.x == b.x) return a.y < b.y;
  return a.x < b.x;
}
bool cmp2(P a, P b) {
  if (a.y == b.y) return a.x < b.x;
  return a.y < b.y;
}
bool cmp3(P a, P b) {
  if (a.y == b.y) return a.x < b.x;
  return a.y > b.y;
}
void add(int x) {
  for (; x <= cnt1; x += x & -x) f[x]++;
}
int sum(int x) {
  int ans = 0;
  for (; x; x -= x & -x) ans += f[x];
  return ans;
}
bool vis[maxn];
int last;
vector<int> v[maxn];
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    p[i] = (P){read(), read()};
  }
  sort(p + 1, p + 1 + n, cmp1);
  last = p[1].x;
  p[1].x = 1, cnt1 = 1;
  for (int i = 2; i <= n; ++i) {
    if (p[i].x == last)
      p[i].x = cnt1;
    else
      last = p[i].x, p[i].x = ++cnt1;
  }
  sort(p + 1, p + 1 + n, cmp2);
  last = p[1].y;
  p[1].y = 1, cnt2 = 1;
  for (int i = 2; i <= n; ++i) {
    if (p[i].y == last)
      p[i].y = cnt2;
    else
      last = p[i].y, p[i].y = ++cnt2;
  }
  sort(p + 1, p + 1 + n, cmp3);
  long long ans = 0;
  int k = 1;
  for (int i = cnt2; i; --i) {
    for (; k <= n && p[k].y >= i; k++) {
      v[i].push_back(p[k].x);
      if (!vis[p[k].x]) {
        vis[p[k].x] = 1;
        add(p[k].x);
      }
    }
    sort(v[i].begin(), v[i].end());
    for (int j = 0; j < v[i].size(); ++j) {
      int p = 0;
      if (j) p = sum(v[i][j - 1]);
      int l = sum(v[i][j]) - p;
      int r = sum(cnt1) - sum(v[i][j]) + 1;
      ans += 1LL * l * r;
    }
  }
  cout << ans << endl;
}
