#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a[3], b[3], i, j, in, ans;
  while (cin >> a[0] >> a[1] >> a[2]) {
    ans = 3000000000000000003;
    b[2] = a[2], b[1] = a[1], b[0] = a[0];
    long long cnt = 0, tot = a[0] + a[1] + a[2];
    for (i = 1; i <= 3; i++) {
      long long mx = 0, present, up = 0, dwn = 0;
      if (a[i - 1] == 0) continue;
      if (i == 2)
        b[0] = (a[0] != 0) ? a[0] + 1 : 0, up = 1;
      else if (i == 3)
        b[0] = (a[0] != 0) ? a[0] + 1 : 0, b[1] = (a[1] != 0) ? a[1] + 1 : 0,
        up = 2;
      mx = max(max(b[0], b[1]), b[2]);
      present = mx * 3;
      if (b[2] == mx)
        dwn = 0;
      else if (b[1] == mx)
        dwn = 1;
      else if (b[0] == mx)
        dwn = 2;
      present -= up + dwn;
      ans = min(ans, present - tot);
    }
    cout << ans << endl;
  }
  return 0;
}
