#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, i, a, b, c;
    cin >> a >> b >> c;
    int d = abs(a - b) + abs(a - c) + abs(b - c);
    if (d >= 4) {
      cout << d - 4 << endl;
    } else {
      cout << "0" << endl;
    }
  }
  return 0;
}
