#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long power(long long p) {
  if (p == 0) return 1;
  long long a = power(p / 2);
  a *= a;
  if (p % 2) a *= 2;
  return a;
}
const long long N = 1e5 + 100;
long long l[N];
long long r[N];
long long n;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  multiset<long long> lset, rset;
  for (long long i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    lset.insert(l[i]);
    rset.insert(r[i]);
  }
  if (n == 1) {
    cout << max(l[0], r[0]) + 1 << '\n';
    return 0;
  }
  long long ans = 0;
  while (lset.size() > 0) {
    auto x = *(lset.rbegin());
    auto y = *(rset.rbegin());
    ans += max(x, y);
    lset.erase(lset.find(x));
    rset.erase(rset.find(y));
  }
  cout << ans + n << '\n';
  return 0;
}
