#include <bits/stdc++.h>
using namespace std;
int main() {
  long long b, s, d, ans = 0, cnt = 0;
  cin >> b >> d >> s;
  long long ma = max(b, max(s, d));
  ans = max(cnt, ma - b - 1) + max(cnt, ma - s - 1) + max(cnt, ma - d - 1);
  cout << ans;
}
