You invited n guests to dinner! You plan to arrange one or more circles of chairs. Each chair is going to be either occupied by one guest, or be empty. You can make any number of circles. 

Your guests happen to be a little bit shy, so the i-th guest wants to have a least l_i free chairs to the left of his chair, and at least r_i free chairs to the right. The "left" and "right" directions are chosen assuming all guests are going to be seated towards the center of the circle. Note that when a guest is the only one in his circle, the l_i chairs to his left and r_i chairs to his right may overlap.

What is smallest total number of chairs you have to use?

Input

First line contains one integer n — number of guests, (1 ⩽ n ⩽ 10^5). 

Next n lines contain n pairs of space-separated integers l_i and r_i (0 ⩽ l_i, r_i ⩽ 10^9).

Output

Output a single integer — the smallest number of chairs you have to use.

Examples

Input

3
1 1
1 1
1 1


Output

6


Input

4
1 2
2 1
3 5
5 3


Output

15


Input

1
5 6


Output

7

Note

In the second sample the only optimal answer is to use two circles: a circle with 5 chairs accomodating guests 1 and 2, and another one with 10 chairs accomodationg guests 3 and 4.

In the third sample, you have only one circle with one person. The guest should have at least five free chairs to his left, and at least six free chairs to his right to the next person, which is in this case the guest herself. So, overall number of chairs should be at least 6+1=7.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class D {
	static long mod=998244353;

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		PriorityQueue<Integer> l=new PriorityQueue<>(), r=new PriorityQueue<>();
		long total=n;
		for (int i=0; i<n; i++) {
			int ll=fs.nextInt(), rr=fs.nextInt();
			total+=ll+rr;
			l.add(ll);
			r.add(rr);
		}
		while (!l.isEmpty()) {
			int ll=l.poll(), rr=r.poll();
			total-=Math.min(ll, rr);
		}
		System.out.println(total);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}
		
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		
	}

	/*static class PollardRho {
		static Random r = new Random();

		static ArrayList<Long> getPrimeFactors(long n, boolean weak) {
			ArrayList<Long> factors = new ArrayList<>();
			getPrimeFactors(n, factors, true);
			// Collections.sort(factors); if you want multiplicities in a row
			return factors;
		}

		static void getPrimeFactors(long n, ArrayList<Long> factors, boolean first) {
			if (first) {
				long d = rho(n); 
				factors.add(d);
				factors.add(n/d);
			}
		}

		// returns a small non-trivial divisor of n (n must not be prime)
		static long rho(long n) {
			if (n <= 3)  return -1;
			if ((n & 1) == 0)  return 2;
			long x, y, d;  BigInteger ab, nb;

			nb = BigInteger.valueOf(n);
			do {
				ab = BigInteger.valueOf(Math.abs(r.nextInt(100_000)) + 2);
				x = y = Math.abs(r.nextInt(100_000)) + 2;
				do {
					x = poly(x, ab, nb);  y = polypoly(y, ab, nb);
					d = gcd(n, Math.abs(x - y));
				} while (d == 1);
			} while (d == n);
			return d;
		}
		
		static long gcd(long a, long b) {
			return b==0?a:gcd(b, a%b);
		}

		static long poly(long x, BigInteger ab, BigInteger nb) {
			BigInteger xb = BigInteger.valueOf(x);
			return xb.multiply(xb).add(ab).mod(nb).longValue();
		}

		static long polypoly(long x, BigInteger ab, BigInteger nb) {
			BigInteger xb = BigInteger.valueOf(x), p = xb.multiply(xb).add(ab);
			return p.multiply(p).add(ab).mod(nb).longValue();
		}
	}
	*/
}
