#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int b, l, d, ans = 0;
  int stayed;
  cin >> b >> l >> d;
  if (b >= l && b >= d)
    stayed = 1;
  else if (l >= b && l >= d)
    stayed = 2;
  else
    stayed = 3;
  if (stayed == 1) {
    if (l < b) ans += b - l - 1;
    if (d < b) ans += b - d - 1;
  } else if (stayed == 2) {
    if (b < l) ans += l - b - 1;
    if (d < l) ans += l - d - 1;
  } else {
    if (b < d) ans += d - b - 1;
    if (l < d) ans += d - l - 1;
  }
  cout << ans;
}
