#include <bits/stdc++.h>
const int maxn = 1e5 + 10;
int n;
int l[maxn], r[maxn];
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &l[i], &r[i]);
  }
  std::sort(l + 1, l + 1 + n);
  std::sort(r + 1, r + 1 + n);
  for (int i = 1; i <= n; ++i) {
    ans += (long long)std::max(l[i], r[i]);
  }
  printf("%I64d\n", (long long)ans + n);
}
