#include <bits/stdc++.h>
using namespace std;
int main() {
  long long arr[3];
  scanf("%I64d%I64d%I64d", &arr[0], &arr[1], &arr[2]);
  sort(arr, arr + 3);
  if (arr[0] == arr[1] && arr[1] == arr[2])
    printf("0\n");
  else if (arr[2] == arr[1] && arr[1] > arr[0]) {
    printf("%I64d\n", arr[2] - arr[0] - 1);
  } else if (arr[2] > arr[1] && arr[1] == arr[0]) {
    printf("%I64d\n", (arr[2] - arr[1] - 1) + (arr[2] - arr[0] - 1));
  } else if (arr[2] > arr[1] && arr[1] > arr[0]) {
    printf("%I64d\n", (arr[2] - arr[1] - 1) + (arr[2] - arr[0] - 1));
  }
}
