#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16;
const int N = 1e5;
long long dp[N + 1];
vector<pair<int, int>> lefts;
vector<pair<int, int>> rights;
long long offer(int i, int h, bool sid) {
  long long res = 0;
  for (int j = 0; j < h; ++j) {
    if (sid) {
      if (lefts[i + j].second == rights[i + (j + 1) % h].second) return INF;
      res += max(lefts[i + j].first, rights[i + (j + 1) % h].first);
    } else {
      if (rights[i + j].second == lefts[i + (j + 1) % h].second) return INF;
      res += max(rights[i + j].first, lefts[i + (j + 1) % h].first);
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    lefts.push_back({l, i});
    rights.push_back({r, i});
  }
  sort(lefts.begin(), lefts.end());
  sort(rights.begin(), rights.end());
  long long res = n;
  for (int i = 0; i < n; ++i) res += max(lefts[i].first, rights[i].first);
  cout << res << '\n';
}
