#include <bits/stdc++.h>
using namespace std;
int main() {
  long long b, d, s, x, y, z, m, t;
  x = y = z = 0;
  cin >> b >> d >> s;
  long long a[3] = {b, d, s};
  sort(a, a + 3);
  if (a[0] == a[2]) {
    cout << 0;
  } else if (a[1] == a[2]) {
    cout << a[2] - a[0] - 1;
  } else {
    cout << 2 * a[2] - a[0] - a[1] - 2;
  }
  return 0;
}
