#include <bits/stdc++.h>
const double pi = acos(-1.0);
using namespace std;
void MOD(long long &x) {
  if (x >= 1000000007) x -= 1000000007;
  if (x < 0) x += 1000000007;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void solve() {
  int n;
  cin >> n;
  pair<long long, int> l[n], r[n];
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    l[i] = {x, i};
    r[i] = {y, i};
  }
  sort(l, l + n);
  sort(r, r + n);
  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    ans += max(l[i].first, r[i].first);
  }
  cout << ans + n;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
