#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;
long long readInt() {
  bool minus1 = false;
  long long result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus1 = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus1)
    return -result;
  else
    return result;
}
int L[MAXN];
int R[MAXN];
int main() {
  int n = readInt();
  for (int i = 1; i <= n; i++) {
    L[i] = readInt();
    R[i] = readInt();
  }
  sort(L + 1, L + 1 + n);
  sort(R + 1, R + 1 + n);
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    res += max(L[i], R[i]);
  }
  cout << res + n;
  return 0;
}
