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