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