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