#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> a >> b >> c;
    cout << max(abs(a - b) + abs(b - c) + abs(a - c) - 4, 0) << endl;
  }
  return 0;
}
