#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long ber, dinn, super, count = 0;
  cin >> ber >> dinn >> super;
  int flag = 0;
  if (ber == dinn && ber == super) {
    count = 0;
    flag = 1;
  } else if ((ber == dinn || ber == super || dinn == super) && !flag) {
    if (ber == dinn) {
      if (super > ber)
        count = (super - ber - 1) * 2;
      else
        count = (ber - 1 - super);
    }
    if (super == dinn) {
      if (super < ber)
        count = (ber - super - 1) * 2;
      else
        count = (super - ber - 1);
    }
    if (ber == super) {
      if (dinn > ber)
        count = (dinn - ber - 1) * 2;
      else
        count = (ber - 1 - dinn);
    }
  } else {
    if (ber > dinn && ber > super)
      count = (ber - dinn - 1) + (ber - super - 1);
    else if (dinn > ber && dinn > super)
      count = (dinn - ber - 1) + (dinn - super - 1);
    else
      count = (super - ber - 1) + (super - dinn - 1);
  }
  cout << count << endl;
}
