#include <bits/stdc++.h>
using namespace std;
const int N(100005);
int n, l[N], r[N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (register int i(1); i <= n; ++i) cin >> l[i] >> r[i];
  sort(l + 1, l + n + 1);
  sort(r + 1, r + n + 1);
  long long ans(n);
  for (register int i(1); i <= n; ++i) ans += (l[i] > r[i] ? l[i] : r[i]);
  cout << ans << "\n";
  return 0;
}
