#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int add(int x, int y) {
  x += y;
  if (x >= mod) return x - mod;
  return x;
}
int sub(int x, int y) {
  x -= y;
  if (x < 0) return x + mod;
  return x;
}
int mul(int x, int y) { return (long long)x * y % mod; }
int x[4][3] = {{0, 0, 0}, {0, 0, 1}, {0, 1, 1}, {1, 1, 1}};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long A, B, C;
  cin >> A >> B >> C;
  long long sol = (long long)(1e18) * 4;
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < 4; ++j) {
      long long a = A, b = B, c = C;
      long long tmp = 0;
      a -= x[i][0];
      a -= x[j][2];
      b -= x[i][1];
      b -= x[j][1];
      c -= x[i][2];
      c -= x[j][0];
      tmp += max(max(a, b), c) * 3 - a - b - c;
      sol = min(sol, tmp);
    }
  cout << sol;
}
