#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005], b[100005];
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d", 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]);
  printf("%lld", ans + n);
  return 0;
}
