#include <bits/stdc++.h>
template <class... Args>
inline __attribute__((always_inline)) void read(Args&... args) {
  (std::cin >> ... >> args);
}
template <class... Args>
inline __attribute__((always_inline)) void write(Args&&... args) {
  (std::cout << ... << std::forward<Args>(args));
}
template <class... Args>
inline __attribute__((always_inline)) void writeln(Args&&... args) {
  write(std::forward<Args>(args)..., '\n');
}
inline __attribute__((always_inline)) void flush() { std::flush(std::cout); }
struct bi_tree {
  std::vector<int> data;
  explicit bi_tree(int sz) : data(sz) {}
  int pref_sum(int r) {
    int res = 0;
    for (; r; r -= r & (-r)) res += data[r - 1];
    return res;
  }
  void add(int i, int d) {
    for (++i; i <= (int)data.size(); i += i & (-i)) data[i - 1] += d;
  }
  int sum(int l, int r) { return pref_sum(r) - pref_sum(l); }
  int get(int i) { return sum(i, i + 1); }
  void set(int pos, int val) {
    int cur = sum(pos, pos + 1);
    if (cur != val) add(pos, val - cur);
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  std::fixed(std::cout).precision(20);
  std::cin.tie(nullptr);
  int n;
  read(n);
  struct point_t {
    int x, y;
  };
  std::vector<point_t> ps(n);
  for (auto& [x, y] : ps) read(x, y);
  std::vector<int> xs;
  xs.reserve(n);
  for (auto p : ps) xs.push_back(p.x);
  std::sort(xs.begin(), xs.end());
  xs.erase(std::unique(xs.begin(), xs.end()), xs.end());
  int cnt_xs = 1 + xs.size();
  for (auto& p : ps)
    p.x = 1 + (std::lower_bound(xs.begin(), xs.end(), p.x) - xs.begin());
  std::sort(ps.begin(), ps.end(), [](const point_t& a, const point_t& b) {
    return a.y != b.y ? a.y > b.y : a.x < b.x;
  });
  bi_tree used_xs(cnt_xs);
  int64_t res = 0;
  xs.clear();
  xs.push_back(0);
  int cur_y = ps[0].y;
  ps.push_back({0, 0});
  for (auto [x, y] : ps) {
    if (cur_y != y) {
      for (int i = 1; i < (int)xs.size(); ++i) {
        int64_t left_ends = used_xs.sum(xs[i - 1] + 1, xs[i] + 1);
        int64_t right_ends = used_xs.sum(xs[i], cnt_xs);
        res += left_ends * right_ends;
      }
      cur_y = y;
      xs.clear();
      xs.push_back(0);
    }
    used_xs.set(x, 1);
    xs.push_back(x);
  }
  writeln(res);
  return 0;
}
