#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000007;
int l[maxn], r[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &l[i], &r[i]);
  }
  sort(l, l + n);
  sort(r, r + n);
  long long sum = n;
  for (int i = 0; i < n; ++i) {
    sum += max(l[i], r[i]);
  }
  printf("%lld\n", sum);
  return 0;
}
