#include <bits/stdc++.h>
constexpr int N = 100005;
using namespace std;
int n, m, a[N], b[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
  }
  sort(a + 1, a + 1 + n);
  sort(b + 1, b + 1 + n);
  long long ans = n;
  for (int i = n; i >= 1; --i) {
    ans += max(a[i], b[i]);
  }
  printf("%lld\n", ans);
}
