#include <bits/stdc++.h>
using namespace std;
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(NULL);
  vector<long long int> v;
  for (long long int i = 0; i < 3; i++) {
    long long int temp;
    cin >> temp;
    v.push_back(temp);
  }
  sort(v.begin(), v.end());
  if (v[0] == v[1] && v[1] == v[2])
    cout << 0 << endl;
  else if (v[0] != v[1] && v[1] == v[2])
    cout << v[2] - v[0] - 1 << endl;
  else {
    cout << (v[2] - v[1]) + (v[2] - v[0]) - 2 << endl;
  }
}
