#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b;
  bool operator<(const node& rhs) const {
    if (a == rhs.a)
      return b < rhs.b;
    else
      return a < rhs.a;
  }
};
int T, n, m, r, cnt;
unsigned long long a[3], maxx, ans;
void read() {
  cin >> a[0] >> a[1] >> a[2];
  maxx = max(a[0], max(a[1], a[2]));
}
void preprocess() {}
void solve() {
  {
    unsigned long long sum = 0;
    for (int k = 0; k <= 2; k++) {
      if (a[k] == maxx || a[k] == maxx - 1) {
        ;
      } else {
        sum += maxx - 1 - a[k];
      }
    }
    cout << sum << endl;
  }
}
int main() {
  {
    read();
    solve();
  }
  return 0;
}
