#include <bits/stdc++.h>
using namespace std;
void file() { freopen("halfnice.in", "r", stdin); }
const int MAX = 3e5 + 1, INF = (1 << 30);
int main() {
  int n;
  long long ans = 0;
  scanf("%d", &n);
  vector<int> l(n), r(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &l[i]), scanf("%d", &r[i]);
  }
  sort(l.begin(), l.end());
  sort(r.begin(), r.end());
  for (int i = 0; i < n; ++i) ans += max(l[i], r[i]) + 1;
  printf("%lld\n", ans);
  return 0;
}
