#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, x;
  cin >> n;
  while (n > 0) {
    cin >> a >> b >> c;
    x = abs(a - b) + abs(b - c) + abs(a - c) - 4;
    if (x <= 0) x = 0;
    cout << x << endl;
    n--;
  }
}
