#include <bits/stdc++.h>
using namespace std;
int l[100005], r[100005];
int main() {
  int n, i;
  cin >> n;
  for (i = 0; i < n; i++) cin >> l[i] >> r[i];
  sort(l, l + n);
  sort(r, r + n);
  long long sum = 0;
  for (i = 0; i < n; i++) {
    sum += max(l[i], r[i]) + 1;
  }
  cout << sum << endl;
  return 0;
}
