#include <bits/stdc++.h>
using namespace std;
bool isvowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' ||
      c == 'E' || c == 'I' || c == 'O' || c == 'U')
    return true;
  return false;
}
bool prime[1000000];
vector<int> primes;
void sieve() {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= 1000000; p++) {
    if (prime[p] == true) {
      for (int i = p * 2; i <= 1000000; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= 1000000; p++)
    if (prime[p]) primes.push_back(p);
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int fast_exp(long long int x, long long int n) {
  long long int ans = 1;
  while (n) {
    if (n & 1) ans *= x;
    n = n >> 1;
    ans *= x * x;
  }
  return ans;
}
long long int mod_exp(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  long long int b, d, s;
  cin >> b >> d >> s;
  long long int m = max(b, max(d, s));
  long long int ans = 0;
  if (b == s && b != d) {
    if (m == d)
      ans = 2 * (d - b) - 2;
    else if (m == b)
      ans = b - d - 1;
  } else if (d == s && d != b) {
    if (m == b)
      ans = 2 * (b - d) - 2;
    else if (m == d) {
      ans = d - b - 1;
    }
  } else if (b == d && b != s) {
    if (m == s)
      ans = 2 * (s - b) - 2;
    else if (m == b)
      ans = b - s - 1;
  } else if (b == d && d == s)
    ans = 0;
  else if (m == b) {
    ans = b - d - 1;
    ans += b - s - 1;
  } else if (m == d) {
    ans = d - b - 1;
    ans += d - s - 1;
  } else if (m == s) {
    ans = s - b - 1;
    ans += s - d - 1;
  }
  cout << ans;
}
