#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int num[N];
int main() {
  long long ans = -1;
  long long a, b, c;
  cin >> a >> b >> c;
  long long mx = max(a, max(b, c));
  long long mn = min(a, min(b, c));
  long long mm = a + b + c - mx - mn;
  if (a == b && b == c)
    cout << 0 << endl;
  else {
    if (mx == mm) {
      cout << mx - mn - 1;
    } else
      cout << 2 * mx - mn - mm - 2 << endl;
  }
  return 0;
}
