#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print_array(T arr[], int size_arr) {
  for (int i = (0); i < (size_arr); i++) {
    cout << arr[i];
    if (i == size_arr - 1)
      cout << endl;
    else
      cout << " ";
  }
}
template <typename T>
void print_vector(vector<T> v) {
  for (int i = (0); i < (v.size()); i++) {
    cout << v[i];
    if (i == v.size() - 1)
      cout << endl;
    else
      cout << " ";
  }
}
template <typename T>
void memset_array(T arr[], T value, int size_arr) {
  for (int i = (0); i < (size_arr); i++) {
    arr[i] = value;
  }
}
bool compare_lexical_string(string a, string b) {
  for (int i = (0); i < (min(a.length(), b.length())); i++) {
    if (a[i] != b[i]) return a[i] < b[i];
  }
  return a.length() < b.length();
}
struct lex_string {
  bool operator()(string a, string b) { return compare_lexical_string(a, b); }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long b, d, s;
  cin >> b >> d >> s;
  long long max_num, min_num;
  max_num = max(b, max(d, s));
  min_num = min(b, min(d, s));
  if (max_num == min_num)
    cout << 0 << endl;
  else {
    if (max_num == b) {
      long long count = 0;
      if (d < b) count += b - 1 - d;
      if (s < b) count += b - 1 - s;
      cout << count << endl;
    } else if (max_num == d) {
      if (d == s)
        cout << d - 1 - b << endl;
      else {
        cout << 2 * d - 2 - b - s << endl;
      }
    } else {
      cout << s - 1 - b + s - 1 - d << endl;
    }
  }
  return 0;
}
