#include <bits/stdc++.h>
using namespace std;
const long long OO = (long long)1e15;
int main() {
  ios_base::sync_with_stdio(false);
  long long a, b, c;
  cin >> a >> b >> c;
  long long m = max(a, max(b, c)) - 1;
  cout << (max(0ll, m - a) + max(0ll, m - b) + max(0ll, m - c)) << endl;
  return 0;
}
