#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long a, b, c;
  long long ca, cb, cc;
  cin >> a >> b >> c;
  long long cont = 0;
  long long menor;
  long long mayor;
  ca = a, cb = b, cc = c;
  mayor = max(ca, max(cb, cc));
  cont = (mayor - ca) + (mayor - cb) + (mayor - cc);
  menor = cont;
  for (int i = 0; i < 5; ++i) {
    for (int j = 0; j < 5; ++j) {
      cont = 0;
      ca = a;
      cb = b;
      cc = c;
      if (i >= 1) {
        ca++;
      }
      if (i >= 2) {
        cb++;
      }
      if (i >= 3) {
        cc++;
      }
      if (j <= 3) {
        cc++;
      }
      if (j <= 2) {
        cb++;
      }
      if (j <= 1) {
        ca++;
      }
      mayor = max(ca, max(cb, cc));
      cont = (mayor - ca) + (mayor - cb) + (mayor - cc);
      menor = cont < menor ? cont : menor;
    }
  }
  cout << menor << endl;
  return 0;
}
