N candidates (numbered from 1 to N) join Chef's firm. The first 5 candidates join on the first day, and then, on every subsequent day, the next 5 candidates join in.  
For example, if there are 12 candidates, candidates numbered 1 to 5 will join on day 1, candidates numbered 6 to 10 on day 2 and the remaining 2 candidates will join on day 3.

Candidate numbered K decided to turn down his offer and thus, Chef adjusts the position by shifting up all the higher numbered candidates. This leads to a change in the joining day of some of the candidates.

Help Chef determine the number of candidates who will join on a different day than expected.

------ Input Format ------ 

- First line will contain T, number of test cases. Then the test cases follow.
- Each test case contains of a single line of input, two space-separated integers N and K denoting the number of candidates and the candidate who turned down the offer.

------ Output Format ------ 

For each test case, output a single integer denoting the number of candidates whose joining day will be changed.

------ Constraints ------ 

$1 ≤ T ≤ 1000$
$2 ≤ N ≤ 1000$
$1 ≤ K ≤ N$

----- Sample Input 1 ------ 
4
7 3
6 6
2 1
14 2
----- Sample Output 1 ------ 
1
0
0
2

----- explanation 1 ------ 
Test case $1$: The original joining day of each candidate is given as $[1, 1, 1, 1, 1, 2, 2]$ but as candidate $3$ turns down his offer, the new joining days are now $[1, 1, NA, 1, 1, 1, 2]$. Candidate numbered $6$ is the only one to have his joining day changed.

Test case $2$: The original joining day of each candidate is given as $[1, 1, 1, 1, 1, 2]$ but as candidate $6$ turns down his offer, the new joining days are now $[1, 1, 1, 1, 1, NA]$. No candidate got his joining day changed.

Test case $3$: The original joining day of each candidate is given as $[1, 1]$ but as candidate $1$ turns down his offer, the new joining days are now $[NA, 1]$. No candidate got his joining day changed.

Test case $4$: The original joining day of each candidate is given as $[1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3]$ but as candidate $2$ turns down his offer, the new joining days are now $[1, NA, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3]$. Candidate numbered $6$ and $11$ are the only ones to have their joining days changed.

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
from math import ceil
n = int(input())
for _ in range(n):
	(N, K) = list(map(int, input().split()))
	print(ceil(N / 5) - ceil(K / 5))


import math
for t in range(int(input())):
	(n, k) = map(int, input().split())
	N = math.ceil(n / 5)
	m = math.ceil(k / 5)
	print(N - m)


import math
T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	print(math.ceil(N / 5) - math.ceil(K / 5))


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(math.ceil(n / 5) - math.ceil(k / 5))


from math import *
for t in range(int(input())):
	(candi, rejected) = map(int, input().split())
	days = candi // 5 if candi % 5 == 0 else candi // 5 + 1
	print(ceil(candi / 5) - ceil(rejected / 5))


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	x = math.ceil(n / 5)
	y = math.ceil(k / 5)
	print(x - y)


import math
for i in range(int(input())):
	(N, K) = map(int, input().split())
	print(math.ceil(N / 5) - math.ceil(K / 5))


import math
t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	print(math.ceil(n / 5) - math.ceil(k / 5))


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = math.ceil(n / 5)
	b = math.ceil(k / 5)
	print(a - b)


import math
for i in range(int(input())):
	(a, b) = map(int, input().split())
	print(math.ceil(a / 5) - math.ceil(b / 5))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	if k % 5 == 0 and n % 5 != 0:
		print(n // 5 - k // 5 + 1)
	elif k % 5 != 0 and n % 5 == 0:
		print(n // 5 - k // 5 - 1)
	else:
		print(n // 5 - k // 5)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	p = n // 5
	q = k // 5
	if n % 5 == 0:
		p -= 1
	if k % 5 == 0:
		q -= 1
	print(p - q)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == k:
		print(0)
	else:
		days = math.ceil(n / 5)
		day = math.ceil(k / 5)
		print(days - day)


import math
t = int(input())
while t > 0:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	print(math.ceil(n / 5) - math.ceil(k / 5))
	t = t - 1


import math
testCase = int(input())
for i in range(testCase):
	(n, k) = map(int, input().split())
	(nday, kday) = (math.ceil(n / 5), math.ceil(k / 5))
	print(nday - kday)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	p = a // 5
	if a % 5 == 0:
		p -= 1
	q = b // 5
	if b % 5 == 0:
		q -= 1
	print(p - q)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans1 = n // 5 + int(n % 5 != 0)
	ans2 = k // 5 + int(k % 5 != 0)
	print(ans1 - ans2)


tc = int(input())
for _ in range(tc):
	(n, k) = list(map(int, input().split()))
	ins = [i // 5 + 1 for i in range(n)]
	afs = [i // 5 + 1 for i in range(n - 1)]
	del ins[k - 1]
	print(sum([i != j for (i, j) in zip(ins, afs)]))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	original_days = [(i - 1) // 5 + 1 for i in range(1, n + 1)]
	k_day = original_days[k - 1]
	original_days.pop(k - 1)
	shifted_days = [(i - 1) // 5 + 1 for i in range(1, n)]
	num_changed = sum([1 for i in range(n - 1) if original_days[i] != shifted_days[i]])
	print(num_changed)


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	joining_day = (K - 1) // 5 + 1
	total_joining_days = (N - 1) // 5 + 1
	candidates_on_wrong_day = max(total_joining_days - joining_day, 0)
	print(candidates_on_wrong_day)


import math
t = int(input())
while t > 0:
	(a, b) = input().split()
	print(math.ceil(int(a) / 5) - math.ceil(int(b) / 5))
	t = t - 1


T = int(input())
for t in range(T):
	(N, K) = map(int, input().split())
	count = 0
	for i in range(1, N + 1):
		original_day = (i - 1) // 5 + 1
		new_day = (i - 2) // 5 + 1 if i > K else original_day
		if original_day != new_day:
			count += 1
	print(count)


t = int(input())
for i in range(0, t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	x = int((n + 4) / 5)
	y = int((k + 4) / 5)
	v = x - y
	print(v)