#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
const ll imax = numeric_limits<ll>::max();
ll ba[] = {0, 0, 0};
ll bb[] = {0, -1, 0};
ll bc[] = {0, -1, -1};
ll aa[] = {-1, -1, 0};
ll ab[] = {0, -1, 0};
ll ac[] = {0, 0, 0};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll a, b, c;
  cin >> a >> b >> c;
  ll mm = min(a, b);
  mm = min(mm, c);
  ll ret = imax;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j) {
      ll la = a + ba[i] + aa[j];
      ll lb = b + bb[i] + ab[j];
      ll lc = c + bc[i] + ac[j];
      ll mm = min(la, lb);
      mm = min(mm, lc);
      ll MM = max(la, lb);
      MM = max(MM, lc);
      ret = min(ret, ((MM - la) + (MM - lb) + (MM - lc)));
    }
  cout << ret << endl;
}
