#include <bits/stdc++.h>
using namespace std;
void simpleSieve(int limit, vector<int> &prime) {
  bool mark[limit + 1];
  memset(mark, true, sizeof(mark));
  for (int p = 2; p * p < limit; p++) {
    if (mark[p] == true) {
      for (int i = p * 2; i < limit; i += p) mark[i] = false;
    }
  }
  for (int p = 2; p < limit; p++) {
    if (mark[p] == true) {
      prime.push_back(p);
      cout << p << "  ";
    }
  }
}
void segmentedSieve(int n) {
  int limit = floor(sqrt(n)) + 1;
  vector<int> prime;
  simpleSieve(limit, prime);
  int low = limit, high = 2 * limit;
  while (low < n) {
    bool mark[limit + 1];
    memset(mark, true, sizeof(mark));
    for (unsigned int i = 0; i < prime.size(); i++) {
      int loLim = floor(low / prime[i]) * prime[i];
      if (loLim < low) loLim += prime[i];
      for (int j = loLim; j < high; j += prime[i]) mark[j - low] = false;
    }
    for (int i = low; i < high; i++)
      if (mark[i - low] == true) cout << i << "  ";
    low = low + limit;
    high = high + limit;
    if (high >= n) high = n;
  }
}
void primeFactors(int n) {
  while (n % 2 == 0) {
    printf("%d ", 2);
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      printf("%d ", i);
      n = n / i;
    }
  }
  if (n > 2) printf("%d ", n);
}
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int power(int x, unsigned int y, int p) {
  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;
}
string revers(string s) {
  int sl = s.length();
  for (int i = 0; i < sl / 2; i++) swap(s[i], s[sl - i - 1]);
  return s;
}
bool isPowerOfTwo(long int x) { return (x && !(x & (x - 1))); }
int setBit(long long int num, int idx, int value = 1) {
  return (value) ? (num | (1 << idx)) : (num & ~(1 << idx));
}
int getbit(long long int num, int idx) { return ((num >> idx) & 1) == 1; }
int cntbit(long long int num) {
  int ret;
  while (num) {
    if (num % 2) ret++;
    num /= 2;
  }
  return ret;
}
string _int_to_binarystr(long long int i) {
  string s;
  if (i == 0) return "0";
  while (i) {
    s += (i % 2 == 0 ? "0" : "1");
    i /= 2;
  }
  return revers(s);
}
int logr(long long int x) {
  int i = 0;
  while (x / 2) {
    x /= 2;
    i++;
  }
  return i;
}
int sumofbit(long long int num) {
  int sum = 0;
  while (num) {
    sum += (num % 10);
    num = num / 10;
  }
  return sum;
}
long long int pow2(int i) {
  int sum = 1;
  while (i--) sum *= 2;
  return sum;
}
int _string_to_int(string s) {
  int res = 0;
  for (int i = 0; i < s.length(); i++) {
    res *= 10;
    res += (s[i] - '0');
  }
  return res;
}
string _int_to_string(int i) {
  string s = "";
  while (i) {
    s += '0' + (i % 10);
    i /= 10;
  }
  reverse(s.begin(), s.end());
  return s;
}
int main() {
  long long int a, b, c;
  cin >> a >> b >> c;
  long long int mx = max(a, max(b, c));
  if (mx == a) {
    long long int m = a > c ? a - c - 1 : a - c;
    long long int g = a > b ? a - b - 1 : a - b;
    cout << m + g;
  } else if (mx == b) {
    long long int m = b > a ? b - a - 1 : b - a;
    long long int g = b > c ? b - c - 1 : b - c;
    cout << m + g;
  } else {
    long long int m = c > a ? c - a - 1 : c - a;
    long long int g = c > b ? c - b - 1 : c - b;
    cout << m + g;
  }
  return 0;
}
