#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int b, d, s, a;
  cin >> b >> d >> s;
  a = max(b, max(d, s)) - 1;
  cout << max(0LL, a - b) + max(0LL, a - d) + max(0LL, a - s) << '\n';
}
