#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long ct = n;
  long long l[n], r[n];
  for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
  sort(l, l + n);
  sort(r, r + n);
  for (int i = 0; i < n; i++) ct += max(l[i], r[i]);
  cout << ct;
  return 0;
}
