#include <bits/stdc++.h>
using namespace std;
int main() {
  ifstream fin("Text.txt");
  int i, j;
  long long a, b, c = 0, p = 0, n = 0, m, k, r;
  vector<long long> vc(3);
  cin >> vc[0] >> vc[1] >> vc[2];
  sort(vc.rbegin(), vc.rend());
  if (vc[1] < vc[0]) {
    c = 3 * vc[0] - 2 - vc[0] - vc[1] - vc[2];
  } else {
    if (vc[1] == vc[2])
      c = 0;
    else {
      c = 3 * vc[0] - 1 - vc[0] - vc[1] - vc[2];
    }
  }
  cout << c << endl;
  return 0;
}
