#include <bits/stdc++.h>
int main() {
  using namespace std;
  long long b, d, s;
  cin >> b >> d >> s;
  long long n, ans;
  n = max(max(b, d), s);
  if (n == b)
    ans = max(b - d - 1, (long long)0) + max(b - s - 1, (long long)0);
  else if (n == d)
    ans = max(d - b - 1, (long long)0) + max(d - s - 1, (long long)0);
  else
    ans = max(s - b - 1, (long long)0) + max(s - d - 1, (long long)0);
  cout << ans;
}
