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