#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int b[3], temp;
  for (int i = 0; i < 3; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      if (b[j] < b[j + 1]) {
        temp = b[j];
        b[j] = b[j + 1];
        b[j + 1] = temp;
      }
    }
  }
  if (b[0] == b[1] && b[1] == b[2]) {
    cout << "0";
    return 0;
  } else
    b[0] != b[1] ? cout << (2 * b[0] - b[1] - b[2] - 2)
                 : cout << b[0] - b[2] - 1;
  ;
  return 0;
}
