B. Playing Games
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
3 11
2 1
5 100
3 10
Output
4
Input
5 10
5 1
6 1
7 1
8 1
9 1
Output
1
Input
5 4
5 1
6 1
7 1
8 1
9 1
Output
0