#include <bits/stdc++.h>
using namespace std;
int n, a[100005], b[100005];
long long ans;
inline int read() {
  int ret = 0;
  bool f = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') f ^= ch == '-', ch = getchar();
  while (ch <= '9' && ch >= '0') ret = ret * 10 + ch - '0', ch = getchar();
  return f ? -ret : ret;
}
int main() {
  ans = n = read();
  for (int i = 1; i <= n; i++) a[i] = read(), b[i] = read();
  sort(a + 1, a + 1 + n), sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) ans += max(a[i], b[i]);
  printf("%lld\n", ans);
  return 0;
}
