#include <bits/stdc++.h>
using namespace std;
int main() {
  pair<long long, int> a[3];
  for (int i = 0; i < 3; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a, a + 3, greater<pair<long long, int> >());
  long long ans = 0;
  for (int i = 0; i < 3; i++) ans += max(0LL, a[0].first - 2 - a[i].first);
  for (int i = 0; i < 3; i++)
    if (a[0].first - a[i].first >= 2) ans++;
  cout << ans << endl;
  return 0;
}
