#include <bits/stdc++.h>
int n;
long long l[100001], r[100001], ans = 0;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d%I64d", &l[i], &r[i]);
  std::sort(l + 1, l + n + 1);
  std::sort(r + 1, r + n + 1);
  for (int i = 1; i <= n; i++) {
    ans += l[i] > r[i] ? l[i] : r[i];
  }
  printf("%I64d\n", ans + 1ll * n);
  return 0;
}
