#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, k;
  cin >> n >> m >> k;
  long long int temp = 0;
  long long int max1 = max(n, max(m, k));
  if (max1 - 1 - n > 0) temp += max1 - 1 - n;
  if (max1 - 1 - m > 0) temp += max1 - 1 - m;
  if (max1 - 1 - k > 0) temp += max1 - 1 - k;
  cout << temp;
  return 0;
}
