#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
void solve() {
  long long i, j, n, sum = 0;
  long long a, b, c;
  cin >> a >> b >> c;
  sum = abs(a - b) + abs(a - c) + abs(b - c);
  if (sum >= 4)
    cout << sum - 4 << endl;
  else
    cout << 0 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
