#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long a[3], i;
  for (i = 0; i < 3; ++i) cin >> a[i];
  sort(a, a + 3);
  long long ans = 0;
  if (a[1] < a[2]) ans += a[2] - a[1] - 1;
  if (a[0] < a[2]) ans += a[2] - a[0] - 1;
  cout << max((long long)0, ans);
  return 0;
}
