#include <bits/stdc++.h>
using namespace std;
void solve()
{
int x[3], ans = INT_MAX;
cin >> x[0] >> x[1] >> x[2];
for (int i = -1; i <= 1; i++)
{
for (int j = -1; j <= 1; j++)
{
for (int k = -1; k <= 1; k++)
{
int a = x[0] + i, b = x[1] + j, c = x[2] + k;
int sum = abs(a - b) + abs(a - c) + abs(b - c);
ans = min(ans, sum);
}
}
}
cout << ans << "\n";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHNvbHZlKCkKewogICAgaW50IHhbM10sIGFucyA9IElOVF9NQVg7CiAgICBjaW4gPj4geFswXSA+PiB4WzFdID4+IHhbMl07CgogICAgZm9yIChpbnQgaSA9IC0xOyBpIDw9IDE7IGkrKykKICAgIHsKICAgICAgICBmb3IgKGludCBqID0gLTE7IGogPD0gMTsgaisrKQogICAgICAgIHsKICAgICAgICAgICAgZm9yIChpbnQgayA9IC0xOyBrIDw9IDE7IGsrKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaW50IGEgPSB4WzBdICsgaSwgYiA9IHhbMV0gKyBqLCBjID0geFsyXSArIGs7CiAgICAgICAgICAgICAgICBpbnQgc3VtID0gYWJzKGEgLSBiKSArIGFicyhhIC0gYykgKyBhYnMoYiAtIGMpOwoKICAgICAgICAgICAgICAgIGFucyA9IG1pbihhbnMsIHN1bSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgY291dCA8PCBhbnMgPDwgIlxuIjsKfQoKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoMCk7CgogICAgaW50IHQ7CiAgICBjaW4gPj4gdDsKCiAgICB3aGlsZSAodC0tKQogICAgewogICAgICAgIHNvbHZlKCk7CiAgICB9Cn0=
NTAKNTIgNDkgNDYKNDkgNDcgNTIKNTIgNDkgNDkKNDQgNDUgNTEKNDYgNDcgNDcKNDcgNDggNDYKNDkgNDQgNDYKNDMgNDQgNDMKNTIgNDkgNDUKNDYgNDggNDkKNDUgNTIgNTIKNTAgNTEgNDcKNDkgNTIgNTIKNDcgNDcgNDQKNDMgNDQgNDYKNDMgNTAgNTEKNDggNTEgNDYKNDcgNDYgNDMKNDYgNDcgNDUKNDMgNDkgNDYKNDggNDcgNTAKNDQgNDMgNDMKNDggNTEgNDcKNDMgNDQgNDcKNDMgNDYgNDYKNDkgNDQgNTIKNTEgNDUgNTAKNTEgNDcgNTEKNDYgNTEgNDYKNDkgNDYgNDQKNDkgNDQgNDcKNDggNTEgNDMKNDcgNTEgNTAKNTAgNTEgNDgKNTEgNTAgNTAKNTIgNTAgNDQKNTIgNDggNTIKNDMgNTAgNDQKNDggNDQgNTIKNTIgNDkgNTIKNTAgNDcgNDUKNDcgNDcgNTIKNDQgNDkgNDkKNTEgNDYgNDkKNTIgNTAgNTIKNDUgNDUgNDkKNDQgNTAgNDQKNTEgNDYgNTEKNDYgNDYgNDgKNDMgNDggNTE=
50
52 49 46
49 47 52
52 49 49
44 45 51
46 47 47
47 48 46
49 44 46
43 44 43
52 49 45
46 48 49
45 52 52
50 51 47
49 52 52
47 47 44
43 44 46
43 50 51
48 51 46
47 46 43
46 47 45
43 49 46
48 47 50
44 43 43
48 51 47
43 44 47
43 46 46
49 44 52
51 45 50
51 47 51
46 51 46
49 46 44
49 44 47
48 51 43
47 51 50
50 51 48
51 50 50
52 50 44
52 48 52
43 50 44
48 44 52
52 49 52
50 47 45
47 47 52
44 49 49
51 46 49
52 50 52
45 45 49
44 50 44
51 46 51
46 46 48
43 48 51