import java.util.*;
public class training_xiaowuc1 {
  public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ret = sc.nextInt();
    while(n-- > 0) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(a <= ret && ret <= b) ret++;
    }
    System.out.println(ret);
  }
}