#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int eat[3];
  for (int i = 0; i < 3; i++) cin >> eat[i];
  int pos = distance(eat, max_element(eat, eat + 3));
  long long int missed = 0, diff;
  for (int i = 0; i < 3; i++) {
    if (i == pos) continue;
    diff = eat[pos] - eat[i] - 1;
    if (diff > 0) missed += diff;
  }
  cout << missed << '\n';
  return 0;
}
