#include <bits/stdc++.h>
using namespace std;
long long b, d, s;
long long a[5];
int main() {
  while (scanf("%lld%lld%lld", &a[0], &a[1], &a[2]) != EOF) {
    sort(a, a + 3);
    b = a[2];
    d = a[1];
    s = a[0];
    long long tian = b - 1;
    long long ans = 0;
    if (d > tian) ans++;
    if (s > tian) ans++;
    tian *= 2;
    tian += ans;
    tian -= d;
    tian -= s;
    printf("%lld\n", tian);
  }
  return 0;
}
