#include <bits/stdc++.h>
int main() {
  long long int dif1, dif2, dif3, a, b, c;
  int cases, i;
  scanf("%d", &cases);
  for (i = 0; i < cases; i++) {
    scanf("%lld%lld%lld", &a, &b, &c);
    dif1 = a - b;
    dif2 = b - c;
    dif3 = a - c;
    if (dif1 < 0) dif1 = dif1 * -1;
    if (dif2 < 0) dif2 = dif2 * -1;
    if (dif3 < 0) dif3 = dif3 * -1;
    if ((dif1 + dif2 + dif3) <= 4)
      printf("0\n");
    else
      printf("%d\n", (dif1 + dif2 + dif3) - 4);
  }
}
