#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
ll b, d, s;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> b >> d >> s;
vector<ll> a;
a.pb(b);
a.pb(d);
a.pb(s);
sort(a.rbegin(), a.rend());
ll ans = 0;
if(a[0]-a[1])
ans += a[0]-a[1]-1;
if(a[0]-a[2])
ans += a[0]-a[2]-1;
cout << ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgcGIgcHVzaF9iYWNrCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCmxsIGIsIGQsIHM7CgppbnQgbWFpbigpIHsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7IGNpbi50aWUoMCk7IGNvdXQudGllKDApOwogICAgY2luID4+IGIgPj4gZCA+PiBzOwogICAgdmVjdG9yPGxsPiBhOwogICAgYS5wYihiKTsKICAgIGEucGIoZCk7CiAgICBhLnBiKHMpOwogICAgc29ydChhLnJiZWdpbigpLCBhLnJlbmQoKSk7ICAKICAgIGxsIGFucyA9IDA7CiAgICBpZihhWzBdLWFbMV0pCiAgICAgICAgYW5zICs9IGFbMF0tYVsxXS0xOwogICAgaWYoYVswXS1hWzJdKQogICAgICAgIGFucyArPSBhWzBdLWFbMl0tMTsKICAgIGNvdXQgPDwgYW5zOyAKICAgIHJldHVybiAwOwp9