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