#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
int T, n, m;
int l[100005], r[100005];
long long ans;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> l[i] >> r[i];
  sort(l + 1, l + 1 + n);
  sort(r + 1, r + 1 + n);
  for (int i = 1; i <= n; i++) ans += max(l[i], r[i]);
  cout << ans + n << endl;
}
