#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int l[maxn], r[maxn];
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
  sort(l, l + n);
  sort(r, r + n);
  long long ans = n;
  for (int i = 0; i < n; i++) ans += max(l[i], r[i]);
  cout << ans << endl;
  return 0;
}
