#include <bits/stdc++.h>
using namespace std;
void solve()
{
int a, b, c;
cin >> a >> b >> c;
double x[3];
x[0] = a, x[1] = b, x[2] = c;
// double avg_d = (x[0] + x[1] + x[2]) / 3;
int avg = ceil((x[0] + x[1] + x[2]) / 3);
for (int i = 0; i < 3; i++)
{
if (x[i] > avg)
x[i]--;
else if (x[i] < avg)
x[i]++;
}
int ans = abs(x[0] - x[1]) + abs(x[0] - x[2]) + abs(x[1] - x[2]);
cout << ans << "\n";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHNvbHZlKCkKewogICAgaW50IGEsIGIsIGM7CiAgICBjaW4gPj4gYSA+PiBiID4+IGM7CgogICAgZG91YmxlIHhbM107CiAgICB4WzBdID0gYSwgeFsxXSA9IGIsIHhbMl0gPSBjOwoKICAgIC8vIGRvdWJsZSBhdmdfZCA9ICh4WzBdICsgeFsxXSArIHhbMl0pIC8gMzsKCiAgICBpbnQgYXZnID0gY2VpbCgoeFswXSArIHhbMV0gKyB4WzJdKSAvIDMpOwoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgMzsgaSsrKQogICAgewogICAgICAgIGlmICh4W2ldID4gYXZnKQogICAgICAgICAgICB4W2ldLS07CiAgICAgICAgZWxzZSBpZiAoeFtpXSA8IGF2ZykKICAgICAgICAgICAgeFtpXSsrOwogICAgfQoKICAgIGludCBhbnMgPSBhYnMoeFswXSAtIHhbMV0pICsgYWJzKHhbMF0gLSB4WzJdKSArIGFicyh4WzFdIC0geFsyXSk7CgogICAgY291dCA8PCBhbnMgPDwgIlxuIjsKfQoKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoMCk7CgogICAgaW50IHQ7CiAgICBjaW4gPj4gdDsKCiAgICB3aGlsZSAodC0tKQogICAgewogICAgICAgIHNvbHZlKCk7CiAgICB9Cn0=