#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long int l[n], r[n];
  for (int i = 0; i < n; ++i) {
    cin >> l[i] >> r[i];
  }
  sort(l, l + n);
  sort(r, r + n);
  long long int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += max(l[i], r[i]) + 1;
  }
  cout << ans;
}
