#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
int d1[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int d2[8][2] = {{1, 0}, {0, 1},  {0, -1}, {-1, 0},
                {1, 1}, {-1, 1}, {1, -1}, {-1, -1}};
long long cnt(long long a, long long b, long long c) {
  long long mx = max((a), max((b), (c)));
  return mx - a + mx - b + mx - c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long b, d, s;
  cin >> b >> d >> s;
  long long ans = std::numeric_limits<long long>::max();
  ans = min(ans, cnt(b + 2, d + 2, s + 2));
  ans = min(ans, cnt(b + 1, d + 2, s + 2));
  ans = min(ans, cnt(b + 1, d + 1, s + 2));
  ans = min(ans, cnt(b + 1, d + 1, s + 1));
  ans = min(ans, cnt(b + 2, d + 2, s + 1));
  ans = min(ans, cnt(b + 1, d + 2, s + 1));
  ans = min(ans, cnt(b + 1, d + 1, s + 1));
  ans = min(ans, cnt(b + 1, d + 1, s));
  ans = min(ans, cnt(b + 2, d + 1, s + 1));
  ans = min(ans, cnt(b + 1, d + 1, s + 1));
  ans = min(ans, cnt(b + 1, d, s + 1));
  ans = min(ans, cnt(b + 1, d, s));
  ans = min(ans, cnt(b, d + 1, s + 1));
  ans = min(ans, cnt(b, d, s + 1));
  ans = min(ans, cnt(b, d, s));
  cout << ans << "\n";
}
