witch-the-great-and-powerful-17
Source: hackerearth
Difficulty: EASY

A witch of magic-land captured three prisoners who were trying to enter in magic-land without the permission of witch. The prisoners have distinct integral height. She gave them punishment called "Painful height change". In this punishment witch changes their height by using magic which gave them tremendous amount of pain and she enjoys that pain as a game.

The punishment is as follows: 

She stand them in increasing order of their height. Now she wants to give them maximum pain. For this she chooses one of the outer prisoner (first or third prisoner) and changes his height to any integer value between the height of remaining 2 prisoners keeping that no two prisoners have same height and this process of punishment goes on. As she wants to give them maximum punishment, So she needs your help to find maximum numbers of valid moves she can make.

Input :
The first line contains the number of test cases T . Each test case consists of three space separated positive integer - P, Q and R representing the initial height of prisoners. 

Output : 
For each test case output maximum numbers of valid moves that witch can make.

Constraints :
1 ≤ T ≤ 100
1 ≤ P < Q < R ≤ 10^16

SAMPLE INPUT
2
1 2 4
2 4 8

SAMPLE OUTPUT
1
3

Explanation

For second sample :
Initial heights are 2 4 8 . now witch will change 2 into 7 which is between 4 and 8 and first valid move is counted.
now sequence becomes 4 7 8 and she will change 8 into 5 which is between 4 and 7 and  second valid move is counted.
now sequence becomes 4 5 7 and she will change 4 into 6 which is between 5 and 7 and  third valid move is counted.
now sequence becomes 5 6 7 and she can not make any further valid move. so total valid moves are 3.
she can not get more then 3 in any other way.


for i in range(int(input())):
	pqr=[int(x) for x in input().split()]
	pqr.sort()
	print(max(pqr[1]-pqr[0],pqr[2]-pqr[1])-1)


T = int(input())
for i in range(T):
	h  = list(map(int, input().split(" ")))
	print(max(h[2]-h[1],h[1]-h[0])-1)


test=eval(input())
for i in range(test):
	p,q,r=list(map(int,input().split()))
	count1=r-q-1
	count2 = q-p-1
	count1=max(count1,count2)
	if count1<0:
		print(0)
	else:
		print(count1)
	



for _ in range(eval(input())):
	a, b, c = sorted(map(int, input().split()))
	print(max(b - a, c - b) - 1)



for _ in range(eval(input())):
	a, b, c = sorted(map(int, input().split()))
	print(max(b - a, c - b) - 1)


def sortThem(p, q, r):
	data = [p, q, r]
	data.sort()
	return data[0], data[1], data[2]

T = int(input())

for i in range(T):
	p, q, r = input().split()
	p = int(p)
	q = int(q)
	r = int(r)
	p, q, r = sortThem(p, q, r)
	a, b, c = p, q, r
	a = c - 1
	countOne = a - b
	a, b, c = p, q, r
	c = a + 1
	countTwo = b - c
	
	if countOne >= countTwo:
		print(countOne)
	else:
		print(countTwo)