#include <bits/stdc++.h>
using namespace std;
template <typename T>
T id(T b) {
  return b;
};
template <class It>
bool all(It f, It l) {
  return std::all_of(f, l, id<bool>);
}
template <class It>
bool any(It f, It l) {
  return std::any_of(f, l, id<bool>);
}
template <typename T>
void chmax(T &x, T y) {
  if (x < y) x = y;
}
template <typename T>
void chmin(T &x, T y) {
  if (x > y) x = y;
}
const int MAX_N = 200000;
int n;
map<int, vector<int>, greater<int>> group_y;
vector<int> idx;
struct bit {
  int n;
  vector<int> b;
  bit(int n) : n(n), b(vector<int>(n + 1)) {}
  long long sum(int i) {
    long long s = 0;
    while (i > 0) {
      s += b[i];
      i -= i & -i;
    }
    return s;
  }
  long long sum(int i, int j) { return sum(j) - sum(i - 1); }
  void add(int i, int x) {
    while (i <= n) {
      b[i] += x;
      i += i & -i;
    }
  }
};
size_t idx_of(int v) {
  return lower_bound(idx.begin(), idx.end(), v) - idx.begin();
}
int main() {
  cin >> n;
  idx.push_back(0);
  for (int i = 0; i < int(n); i++) {
    int x, y;
    cin >> x >> y;
    group_y[y].push_back(x);
    idx.push_back(x);
  }
  sort(idx.begin(), idx.end());
  idx.erase(unique(idx.begin(), idx.end()), idx.end());
  for (auto &p : group_y) sort(p.second.begin(), p.second.end());
  bit b(MAX_N);
  long long res = 0;
  for (auto p : group_y) {
    for (int x : p.second) {
      int i = idx_of(x);
      if (b.sum(i, i) == 0) b.add(i, 1);
    }
    int prev = 0;
    for (int x : p.second) {
      int i = idx_of(x);
      long long temp = b.sum(prev + 1, i) * b.sum(i, MAX_N);
      res += temp;
      prev = i;
    }
  }
  cout << res << endl;
  return 0;
}
