#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
vector<long long> v[N];
long long vis[N], number[N], ss;
long long pm[N + 10], a[N], b[N + 10];
long long odd[N], even[N];
long long h[N], h1[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long a, c, b;
  cin >> a >> b >> c;
  long long sum = 0;
  long long mm = max(a, b);
  mm = max(mm, c);
  if (a < mm - 1) {
    sum += mm - 1 - a;
  }
  if (b < mm - 1) sum += mm - 1 - b;
  if (c < mm - 1) sum += mm - 1 - c;
  cout << sum << " ";
}
