#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30);
int main() {
  int n;
  cin >> n;
  vector<long long> A(n), B(n);
  for (int i = 0; i < n; i++) cin >> A[i] >> B[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) ans += max(A[i], B[i]);
  cout << ans + n << endl;
  return 0;
}
