#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 1000005;
const double PI = acos(-1.0);
const double EPS = (1e-7);
long long GCD(long long a, long long b) { return ((!b) ? a : GCD(b, a % b)); }
long long LCM(long long a, long long b) { return a / (GCD(a, b)) * b; }
long long nCr(long long n, long long r) {
  if (n < r) return 0;
  if (r == 0) return 1;
  return n * nCr(n - 1, r - 1) / r;
}
bool isPrime(long long n) {
  if (n == 2) return 1;
  if (n < 2 || n % 2 == 0) return 0;
  for (long long i = 3; i * i <= n; i += 2)
    if (n % i == 0) return 0;
  return 1;
}
vector<int> primeFactors(int n) {
  vector<int> v;
  while (n % 2 == 0) {
    v.push_back(2);
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      cout << i << " ";
      v.push_back(i);
      n = n / i;
    }
  }
  if (n > 2) v.push_back(n);
  return v;
}
int countPrimesInRange_sieve(int n) {
  vector<bool> isPrime(n + 1, true);
  isPrime[0] = isPrime[1] = 0;
  for (long long i = 2; i * i <= n; ++i) {
    if (isPrime[i]) {
      for (int j = i * 2; j <= n; j += i) isPrime[j] = 0;
    }
  }
  int cnt = 0;
  for (int i = 0; i < (int)isPrime.size(); ++i)
    if (isPrime[i]) cnt++;
  return cnt;
}
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
int random(int min, int max) {
  static bool first = true;
  if (first) {
    srand(time(NULL));
    first = false;
  }
  return min + rand() % ((max + 1) - min);
}
bool isPalindrome(string str) {
  long long l = 0;
  long long h = ((int)(str).size()) - 1;
  while (h > l) {
    if (str[l++] != str[h--]) {
      return 0;
    }
  }
  return 1;
}
void replaceAll(string &s, const string &search, const string &replace) {
  for (size_t pos = 0;; pos += replace.length()) {
    pos = s.find(search, pos);
    if (pos == string::npos) break;
    s.erase(pos, search.length());
    s.insert(pos, replace);
  }
}
int toInt(const string &t) {
  int temp = 0;
  for (char c : t) {
    temp = 10 * temp + (c - '0');
  }
  return temp;
}
inline string toString(int num) {
  ostringstream str1;
  str1 << num;
  string res = str1.str();
  return res;
}
inline void removeAllOccurences(string &s, char c) {
  s.erase(std::remove(s.begin(), s.end(), c), s.end());
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int tc;
  cin >> tc;
  long long a, b, c;
  while (tc--) {
    cin >> a >> b >> c;
    cout << max((long long)0, abs(a - b) + abs(a - c) + abs(b - c) - 4) << endl;
  }
  return 0;
}
