#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long int a, b, c;
  cin >> a >> b >> c;
  long long int ans = 0;
  long long int mx;
  mx = max(max(a, b), c);
  if (mx == a) ans++;
  if (mx == b) ans++;
  if (mx == c) ans++;
  cout << ans + (mx - 1 - b) + (mx - 1 - a) + (mx - 1 - c);
}
