#include <bits/stdc++.h>
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);
  long long int n;
  std::cin >> n;
  std::vector<long long int> l;
  std::vector<long long int> r;
  for (long long int j = 0; j < n; j++) {
    long long int left, right;
    std::cin >> left >> right;
    l.push_back(left);
    r.push_back(right);
  }
  std::sort(l.begin(), l.end());
std:
  sort(r.begin(), r.end());
  long long int ans = 0;
  for (long long int j = 0; j < n; j++) {
    ans += std::max(l[j], r[j]);
  }
  ans += n;
  std::cout << ans;
  return 0;
}
