#include <bits/stdc++.h>
using namespace std;
const long long MN = 2e5 + 10, inf = 1e9;
long long n;
vector<long long> l, r;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long L, R;
    cin >> L >> R;
    r.push_back(R);
    l.push_back(L);
  }
  sort(r.begin(), r.end());
  sort(l.begin(), l.end());
  reverse(r.begin(), r.end());
  reverse(l.begin(), l.end());
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ans += max(l[i], r[i]);
  }
  cout << ans + n << endl;
}
