#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int main() {
  long long int u, a, b, c, v, n, m, temp = 0, mx = 0, sum = 0, T;
  long long int aa[N];
  for (int i = 0; i < 3; ++i) {
    cin >> aa[i];
  }
  sort(aa, aa + 3);
  aa[1] = aa[1] - aa[0];
  aa[2] = aa[2] - aa[0];
  aa[0];
  a = aa[2] - 1 + aa[2] - 1 - aa[1];
  if (aa[0] == aa[1] == aa[2])
    cout << 0 << endl;
  else if (aa[1] == aa[2]) {
    cout << a + 1 << endl;
  } else
    cout << a << endl;
  return 0;
}
