#include <bits/stdc++.h>
using namespace std;
const long long N = 1000005;
long long n, a[N], b[N];
signed main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i] >> b[i];
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) ans += max(a[i], b[i]);
  cout << ans + n;
}
