#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007LL;
int n;
int l[200005], r[200005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &l[i], &r[i]);
  }
  sort(l + 1, l + n + 1);
  sort(r + 1, r + n + 1);
  long long ans = n;
  for (int i = n; i >= 1; --i) {
    ans += max(l[i], r[i]);
  }
  cout << ans << endl;
  return 0;
}
