#include <bits/stdc++.h>
using integer = unsigned long long;
void answer(integer v) { std::cout << v << '\n'; }
void solve(integer b, integer d, integer s) {
  const integer g = std::max({b, d, s});
  if (b == g) {
    const integer dd = std::max(b - 1, d) - d;
    const integer ds = std::max(b - 1, s) - s;
    return answer(dd + ds);
  }
  if (d == g) {
    const integer ds = std::max(d - 1, s) - s;
    const integer db = std::max(d - 1, b) - b;
    return answer(ds + db);
  }
  if (s == g) {
    const integer db = std::max(s - 1, b) - b;
    const integer dd = std::max(s - 1, d) - d;
    return answer(db + dd);
  }
}
int main() {
  integer b, d, s;
  std::cin >> b >> d >> s;
  solve(b, d, s);
  return 0;
}
