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