#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    long long ans = abs(a - b) + abs(a - c) + abs(b - c);
    cout << max(0ll, ans - 4) << "\n";
  }
  return 0;
}
