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