#include <bits/stdc++.h>
using namespace std;
int T, x;
int main() {
  long long n, l[100010], r[100010], ans = 0;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
  }
  sort(l + 1, l + n + 1);
  sort(r + 1, r + n + 1);
  for (int i = 1; i <= n; i++) {
    ans += max(l[i], r[i]) + 1;
  }
  cout << ans << endl;
  return 0;
}
