#include <bits/stdc++.h>
using namespace std;
long long ans, n, k, m, v, l, r, asdfghjkl, qwertyui, zxcvbnm, oiuytre,
    lkjgfdsa, mnbvcxz, x, y;
long long i, j, a[100002], b[100002], d[100002], l1, l2, r1, r2;
long long mn, xm, ym, mnd, mnv, pos;
long long s;
char c;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if (a[2] == a[1] && a[1] == a[0]) return cout << 0, 0;
  if (a[2] == a[1]) {
    ans = a[2] - a[0] - 1;
    cout << ans;
    return 0;
  }
  ans = 2 * a[2] - a[1] - a[0] - 2;
  cout << ans;
}
