#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, ans = 0;
  cin >> n;
  long long l[n], r[n];
  for (long long int i = 0; i < n; i++) cin >> l[i] >> r[i];
  sort(l, l + n);
  sort(r, r + n);
  for (long long int i = 0; i < n; i++) ans += max(l[i], r[i]);
  cout << ans + n;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long test_cases = 1;
  for (long long t = 1; t <= test_cases; t++) solve(), cout << "\n";
  ;
  return 0;
}
