#include <bits/stdc++.h>
using namespace std;
long long n, l[100005], r[100005];
signed main() {
  scanf("%lld", &n);
  long long ans = 0;
  for (register long long i = 1; i <= n; i++) {
    scanf("%lld%lld", &l[i], &r[i]);
  }
  sort(l + 1, l + n + 1);
  sort(r + 1, r + n + 1);
  for (register long long i = 1; i <= n; i++) {
    ans += max(l[i], r[i]);
  }
  ans += n;
  cout << ans;
}
