#include <bits/stdc++.h>
using namespace std;
template <typename T>
void pr(vector<T> &v) {
  for (int i = 0; i < (int)(v).size(); i++) cout << v[i] << " ";
  cout << '\n';
  ;
}
template <typename T>
void pr(vector<vector<T>> &v) {
  for (int i = 0; i < (int)(v).size(); i++) {
    pr(v[i]);
  }
}
template <typename T>
void re(T &x) {
  cin >> x;
}
template <typename T>
void re(vector<T> &a) {
  for (int i = 0; i < (int)(a).size(); i++) re(a[i]);
}
template <class Arg, class... Args>
void re(Arg &first, Args &...rest) {
  re(first);
  re(rest...);
}
template <typename T>
void pr(T x) {
  cout << x << '\n';
  ;
}
template <class Arg, class... Args>
void pr(const Arg &first, const Args &...rest) {
  cout << first << " ";
  pr(rest...);
  cout << '\n';
  ;
}
void ps() {
  cout << '\n';
  ;
}
template <class T, class... Ts>
void ps(const T &t, const Ts &...ts) {
  cout << t;
  if (sizeof...(ts)) cout << " ";
  ps(ts...);
}
const long long MOD = 998244353;
long double PI = 4 * atan(1);
long double eps = 1e-12;
int LSOne(int b) { return b & -b; }
class FenwickTree {
 private:
  vector<int> ft;

 public:
  FenwickTree(int n) { ft.assign(n + 1, 0); }
  int rsq(int b) {
    int sum = 0;
    for (; b; b -= LSOne(b)) {
      sum += ft[b];
    }
    return sum;
  }
  int rsq(int a, int b) { return rsq(b) - (a == 1 ? 0 : rsq(a - 1)); }
  void adjust(int k, int v) {
    for (; k < (int)ft.size(); k += LSOne(k)) {
      ft[k] += v;
    }
  }
};
FenwickTree ft(200005);
int x[200005], y[200005];
int sx[200005], sy[200005];
vector<vector<int>> vec(200005);
int nx, ny;
long long tri(long long a) { return (a * (a + 1)) / 2; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    sx[i] = x[i];
    sy[i] = y[i];
  }
  sort(sx, sx + n);
  sort(sy, sy + n);
  nx = unique(sx, sx + n) - sx;
  ny = unique(sy, sy + n) - sy;
  for (int i = 0; i < n; i++) {
    x[i] = lower_bound(sx, sx + nx, x[i]) - sx + 1;
    y[i] = lower_bound(sy, sy + ny, y[i]) - sy + 1;
    vec[y[i]].push_back(x[i]);
  }
  long long res = 0;
  for (int i = ny + 1 - 1; i >= 1; i--) {
    sort(vec[i].begin(), vec[i].end());
    int lst = 0;
    for (int j : vec[i]) {
      int p = ft.rsq(lst + 1, j - 1);
      lst = j;
      if (p <= 0) continue;
      res -= tri((long long)p);
    }
    int p = ft.rsq(lst + 1, nx);
    if (p > 0) res -= tri((long long)p);
    for (int j : vec[i]) {
      if (!ft.rsq(j, j)) ft.adjust(j, 1);
    }
    p = ft.rsq(nx);
    res += tri((long long)p);
  }
  cout << res << '\n';
  ;
}
