#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> a[100100];
vector<long long> v, v2;
int main() {
  int n, i;
  cin >> n;
  long long Answer = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    v.push_back(a[i].first);
    v2.push_back(a[i].second);
  }
  sort(v.rbegin(), v.rend());
  sort(v2.rbegin(), v2.rend());
  for (i = 0; i < n; i++) {
    Answer += max(v[i], v2[i]) + 1;
  }
  cout << Answer;
  return 0;
}
