var arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var id = arr[0]; var gate = arr[1];
var array = Array(count:arr[0], repeatedValue: 0 )

var min = 0
var max = 1000000000000000
var o = 0
//arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
while let line = readLine() {
  arr=line.characters.split{$0==" "}.map{Int(String($0))!}
  
  if( arr[0] - 1 > min ) {
    min = arr[0] - 1
  }
  
  if( max > arr[1] - 1 ) {
    max = arr[1] - 1
  }
     
  for var i = min; i <= max; i += 1 {
    array[i] += 1;
  }
  
}

let newArray = array.filter { $0 == gate }
print( newArray.count )