#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
vector<int> L, R;
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int l, r;
    scanf("%d", &l);
    scanf("%d", &r);
    L.push_back(l);
    R.push_back(r);
  }
  sort((L).begin(), (L).end());
  sort((R).begin(), (R).end());
  long long int ans = 0;
  for (int i = 0; i <= n - 1; i++) {
    ans += max(L[i], R[i]);
  }
  printf("%lld\n", ans + n);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
