// Arup Guha
// 2/24/2024
// Solution to SER D2 Problem L: Training

import java.util.*;

public class l {

	public static void main(String[] args) {
	
		// Get number of options and current level.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int s = stdin.nextInt();
		
		// Process options.
		for (int i=0; i<n; i++) {
			
			// Get option.
			int low = stdin.nextInt();
			int high = stdin.nextInt();
			
			// Greedy works because it's better to get to a level earlier than
			// later...
			if (s >= low && s <= high)
				s++;
		}
		
		// Ta da!
		System.out.println(s);
	}
}