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 )

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

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