#include <bits/stdc++.h>
using namespace std;
int Set(int n, int pos) { return n = n | (1 << pos); }
int reset(int n, int pos) { return n = n & ~(1 << pos); }
bool check(int n, int pos) { return (bool)(n & (1 << pos)); }
int main() {
  unsigned long long b, d, s;
  cin >> b >> d >> s;
  unsigned long long mx = max(b, max(d, s));
  if (b == mx && d != mx && s != mx) {
    cout << ((b - 1) * 2) - (d + s);
    return (0);
  } else if (d == mx && b != mx && s != mx) {
    cout << ((d - 1) * 2) - (b + s);
    return (0);
  } else if (mx == s && b != mx && d != mx) {
    cout << ((s - 1) * 2) - (d + b);
    return (0);
  } else if (b == d && b != s) {
    cout << (b - 1) - s;
    return (0);
  } else if (d == s && d != b) {
    cout << (d - 1) - b;
    return (0);
  } else if (b == s && b != d) {
    cout << b - 1 - d;
    return (0);
  } else if (b == d && b == s) {
    cout << 0;
    return (0);
  }
}
