#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c)
    cout << 0 << endl;
  else if (a > b && c > b && a > c) {
    long long x = 0;
    a -= 1;
    x = (a - b) + (a - c);
    cout << x << endl;
  } else if ((a == c && a > b)) {
    long long x = 0;
    x += (a - b - 1);
    cout << x << endl;
  } else if ((a == b && b > c)) {
    long long x = 0;
    x += (a - c - 1);
    cout << x << endl;
  } else if ((b == c && a < b)) {
    long long x = 0;
    x += (b - a - 1);
    cout << x << endl;
  } else if (b > c && b > a) {
    long long x = 0;
    x = (b - a - 1) + (b - c - 1);
    cout << x << endl;
  } else {
    long long x = 0;
    long long m = max(a, max(b, c));
    x = a + b + c;
    x = m * 3 - x - 2;
    cout << x << endl;
  }
  return 0;
}
