Three friends are going to meet each other. Initially, the first friend stays at the position $x = a$, the second friend stays at the position $x = b$ and the third friend stays at the position $x = c$ on the coordinate axis $Ox$.

In one minute each friend independently from other friends can change the position $x$ by $1$ to the left or by $1$ to the right (i.e. set $x := x - 1$ or $x := x + 1$) or even don't change it.

Let's introduce the total pairwise distance — the sum of distances between each pair of friends. Let $a'$, $b'$ and $c'$ be the final positions of the first, the second and the third friend, correspondingly. Then the total pairwise distance is $|a' - b'| + |a' - c'| + |b' - c'|$, where $|x|$ is the absolute value of $x$.

Friends are interested in the minimum total pairwise distance they can reach if they will move optimally. Each friend will move no more than once. So, more formally, they want to know the minimum total pairwise distance they can reach after one minute.

You have to answer $q$ independent test cases.


-----Input-----

The first line of the input contains one integer $q$ ($1 \le q \le 1000$) — the number of test cases.

The next $q$ lines describe test cases. The $i$-th test case is given as three integers $a, b$ and $c$ ($1 \le a, b, c \le 10^9$) — initial positions of the first, second and third friend correspondingly. The positions of friends can be equal.


-----Output-----

For each test case print the answer on it — the minimum total pairwise distance (the minimum sum of distances between each pair of friends) if friends change their positions optimally. Each friend will move no more than once. So, more formally, you have to find the minimum total pairwise distance they can reach after one minute.


-----Example-----
Input
8
3 3 4
10 20 30
5 5 5
2 4 3
1 1000000000 1000000000
1 1000000000 999999999
3 2 5
3 2 6

Output
0
36
0
0
1999999994
1999999994
2
4

Difficulty: introductory

Starter code:

Solutions:
t=int(input())
for nt in range(t):
	a,b,c=map(int,input().split())
	print (max(0,abs(a-b)+abs(b-c)+abs(a-c)-4))

for _ in range(int(input())):
    a,b,c = map(int, input().split())
    pd = abs(a-b) + abs(b-c) + abs(a-c)
    for x in range(-1, 2):
        for y in range(-1, 2):
            for z in range(-1, 2):
                a1, b1, c1 = a+x, b+y, c+z
                pd = min(pd, abs(a1-b1) + abs(b1-c1) + abs(a1-c1))
    print(pd)

q = int(input())

for case in range(q):
    a, b, c = list(map(int, input().split()))
    sm = abs(c - a) + abs(b - a) + abs(b - c)
    ans = max(0, sm - 4)
    print(ans) 

for _ in range(int(input())):
	l=sorted(list(map(int,input().split())))
	ans=2*(l[2]-l[0])
	for i in [-1,0,1]:
		for j in [-1,0,1]:
			for k in [-1,0,1]:
				L=list(l)
				L[0]+=i
				L[1]+=j
				L[2]+=k
				L.sort()
				ans=min(ans,2*(L[2]-L[0]))
	print(ans)


t = int(input())
for i in range(t):
    a,b,c = sorted(map(int,input().split()))
    res = 10 ** 100
    for p in range(-1, 2):
        for q in range(-1, 2):
            for r in range(-1, 2):
                aa = a + p
                bb = b + q
                cc = c + r
                tmp = abs(aa - bb)
                tmp += abs(aa - cc)
                tmp += abs(cc - bb)
                res = min(res, tmp)
    print(res)

#!/usr/bin/env python3
# coding: utf-8
# Last Modified: 12/Dec/19 07:08:37 PM


import sys


def main():
    for tc in range(int(input())):
        a, b, c = get_ints()
        A = [a - 1, a, a + 1]
        B = [b - 1, b, b + 1]
        C = [c - 1, c, c + 1]
        ans = 10 ** 18
        for i in range(3):
            for j in range(3):
                for k in range(3):
                    ans = min(
                        ans, abs(A[i] - B[j]) + abs(A[i] - C[k]) + abs(B[j] - C[k])
                    )
        print(ans)


get_array = lambda: list(map(int, sys.stdin.readline().split()))


get_ints = lambda: list(map(int, sys.stdin.readline().split()))


input = lambda: sys.stdin.readline().strip()


def __starting_point():
    main()

__starting_point()

q = int(input())
for i in range(q):
    [a,b,c] = list(map(int, input().rstrip().split()))
    mi = min(a,b,c)
    ma = max(a,b,c)
    altro = a+b+c-mi-ma
    if mi == ma:
        print(0)
    elif ma - mi == 1:
        print(0)
    else:
        mi += 1
        ma -= 1
        print (2*(ma - mi))

for _ in range(int(input())):
    a, b, c = map(int, input().split())
    ret = float('inf')
    for da in (-1, 0, 1):
        for db in (-1, 0, 1):
            for dc in (-1, 0, 1):
                na, nb, nc = a + da, b + db, c + dc
                ret = min(ret, abs(na - nb) + abs(na - nc) + abs(nb - nc))
    print(ret)

from math import *
import os, sys
from io import BytesIO
def f(a, x):
    if a == x:
        return x
    if a > x:
        return a - 1
    else:
        return a + 1
 
#input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
for i in range(int(input())):
    a, b, c = list(map(int, input().split()))
    x = int((a + b + c) / 3 + 0.5)
    a1, b1, c1 = a, b, c
    print(abs(f(a, x) - f(b, x)) + abs(f(c, x) - f(b, x)) + abs(f(a, x) - f(c, x)))
    


for _ in ' '*int(input()):
    a,b,c = map(int,input().split())
    print(max(abs(a-b)+abs(a-c)+abs(b-c)-4,0))

import sys
import math
t = int(input())
for _ in range(t):
    a, b, c = list(map(int, input().split()))
    maxL = min(a, b, c)
    maxR = max(a, b, c)
    maxR -= 1
    maxL += 1
    print(max(0, (maxR - maxL) * 2))

Q = int(input())
for _ in range(Q):
    a, b, c = tuple(map(int, input().split()))

    A = [a - 1, a, a + 1]
    B = [b - 1, b, b + 1]
    C = [c - 1, c, c + 1]

    comps = []
    for x in A:
        for y in B:
            for z in C:
                comps.append((x, y, z))

    ans = float('inf')
    for a, b, c in comps:
        ans = min(ans, abs(a - b) + abs(a - c) + abs(b - c))

    print(ans)


import sys

q = int(sys.stdin.readline())

def dist(x, y, z):
	return abs(x - y) + abs(x - z) + abs(y - z)

def solve(a, b, c):
	best_dist = 10**18
	for ax in [-1, 0, 1]:
		for bx in [-1, 0, 1]:
			for cx in [-1, 0, 1]:
				best_dist = min(best_dist, dist(a + ax, b + bx, c + cx))
	return best_dist

for _ in range(q):
	a, b, c = map(int, sys.stdin.readline().strip().split(' '))
	print(solve(a, b, c))

test = int(input())
for _ in range(test):
    ans = 10**10
    a,b,c = map(int,input().split())
    for i in range(-1,2):
        for j in range(-1,2):
            for k in range(-1,2):
                ta = a+i
                tb = b+j
                tc = c+k
                ans = min(ans,abs(ta-tb)+abs(tb-tc)+abs(ta-tc))
    print(ans)

q = int(input())
for numbers in range(q):
    a,b,c = list(map(int,input().split()))
    x = max(a,b,c)
    y = min(a,b,c)
    if x - y <=2 :
        print(0)
    else:
        print(2*(x-y-2))