#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
  x = 0;
  T k = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') k = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= k;
}
const int N = 1e5 + 7;
int L[N];
int R[N];
int main() {
  int n;
  read(n);
  for (int i = 0; i < n; ++i) {
    read(L[i]), read(R[i]);
  }
  sort(L, L + n);
  sort(R, R + n);
  long long ans = n;
  for (int i = 0; i < n; ++i) {
    ans += max(L[i], R[i]);
  }
  printf("%lld\n", ans);
  return 0;
}
