#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int NMAX = 100005;
ll l[NMAX], r[NMAX];
int main() {
  ll n, ans = 0;
  cin >> n;
  for (int 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]);
  ans += n;
  cout << ans << endl;
  return 0;
}
