#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)(1e5) + 5;
int l[maxn], r[maxn];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> l[i] >> r[i];
  sort(l + 1, l + n + 1);
  sort(r + 1, r + n + 1);
  long long ret = n;
  for (int i = 1; i <= n; ++i) ret += max(l[i], r[i]);
  cout << ret << endl;
  return 0;
}
