#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 6;
int n, l[N], r[N];
int main(void) {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &l[i], &r[i]);
  }
  sort(l, l + n);
  sort(r, r + n);
  long long rt = n;
  for (int i = 0; i < n; ++i) {
    rt += max(l[i], r[i]);
  }
  cout << rt << endl;
}
