#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, mx, ans;
  cin >> a >> b >> c;
  if (a == b && b == c)
    cout << "0" << endl;
  else {
    mx = max(max(a, b), c);
    if (mx == a && mx == b)
      ans = a - c - 1;
    else if (mx == a && mx == c)
      ans = a - b - 1;
    else if (mx == b && mx == c)
      ans = b - a - 1;
    else if (mx == a) {
      mx = mx - 1;
      ans = (mx - b) + (mx - c);
    } else if (mx == b) {
      mx = mx - 1;
      ans = (mx - a) + (mx - c);
    } else if (mx == c) {
      mx = mx - 1;
      ans = (mx - a) + (mx - b);
    }
    cout << ans << endl;
  }
  return 0;
}
