#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long arr[3];
  cin >> arr[0] >> arr[1] >> arr[2];
  sort(arr, arr + 3);
  if (arr[0] == arr[1] && arr[1] == arr[2]) {
    cout << 0 << "\n";
  } else if (arr[1] == arr[2]) {
    cout << arr[1] - arr[0] - 1 << "\n";
  } else {
    cout << 2 * (arr[2] - 1) - arr[0] - arr[1] << "\n";
  }
  return 0;
}
