#include <bits/stdc++.h>
using namespace std;
long long a, b, c, i, n, h;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if (b > c) {
      h = b;
      b = c;
      c = h;
    }
    if (a > b) {
      h = a;
      a = b;
      b = h;
    }
    if (b > c) {
      h = b;
      b = c;
      c = h;
    }
    if ((c - a) * 2 - 4 > 0)
      cout << (c - a) * 2 - 4 << endl;
    else
      cout << 0 << endl;
  }
}
