import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines n, m=map(int, readline().split()) lr=list(map(int, read().split())) ls=lr[::2] rs=lr[1::2] for i in range(n): if m-1-rs[i]