#include <bits/stdc++.h>
using namespace std;
int main() {
  long long b, d, s, n, m;
  cin >> b >> d >> s;
  if (b == d && d == s) {
    cout << "0";
    return 0;
  }
  if (b >= d && b >= s) {
    if (b == s)
      cout << b - 1 - d;
    else if (b == d)
      cout << b - 1 - s;
    else
      cout << b - 1 - d + b - 1 - s;
    return 0;
  }
  if (d >= b && d >= s) {
    if (b == d)
      cout << b - 1 - s;
    else if (d == s)
      cout << d - 1 - b;
    else
      cout << d - 1 - b + d - 1 - s;
    return 0;
  }
  if (s >= b && s >= d) {
    if (s == d)
      cout << d - 1 - b;
    else if (s == b)
      cout << b - 1 - d;
    else
      cout << s - 1 - b + s - 1 - d;
    return 0;
  }
}
