#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int maxn = 1e5 + 9;
const double pi = 3.14159265358979323846264;
const long long inf = 2e17;
const int mod = 10007;
long long a[maxn], b[maxn];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    ans += 1 + a[i] + b[i];
  }
  sort(a, a + n);
  sort(b, b + n);
  for (int i = 0; i < n; ++i) {
    ans -= min(a[i], b[i]);
  }
  cout << ans;
  return 0;
}
