#include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a == b && b == c) {
// Toate cele trei cifre sunt egale
cout << 0 << endl;
} else if (a == b || a == c || b == c) {
// Două dintre cifre sunt egale
if (a == b) {
if (a > c) {
cout << (a - c - 1) << endl;
} else {
cout << (c - a - 1) << endl;
}
} else if (a == c) {
if (a > b) {
cout << (a - b - 1) << endl;
} else {
cout << (b - a - 1) << endl;
}
} else { // b == c
if (b > a) {
cout << (b - a - 1) << endl;
} else {
cout << (a - b - 1) << endl;
}
}
} else {
// Toate trei cifrele sunt diferite
if (a > b && a > c) {
if (b < c) {
cout << (a - b - 2) << endl;
} else {
cout << (a - c - 2) << endl;
}
} else if (b > a && b > c) {
if (a < c) {
cout << (b - a - 2) << endl;
} else {
cout << (b - c - 2) << endl;
}
} else {
if (a < b) {
cout << (c - a - 2) << endl;
} else {
cout << (c - b - 2) << endl;
}
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgYSwgYiwgYzsKICAgIGNpbiA+PiBhID4+IGIgPj4gYzsKCiAgICBpZiAoYSA9PSBiICYmIGIgPT0gYykgewogICAgICAgIC8vIFRvYXRlIGNlbGUgdHJlaSBjaWZyZSBzdW50IGVnYWxlCiAgICAgICAgY291dCA8PCAwIDw8IGVuZGw7CiAgICB9IGVsc2UgaWYgKGEgPT0gYiB8fCBhID09IGMgfHwgYiA9PSBjKSB7CiAgICAgICAgLy8gRG91xIMgZGludHJlIGNpZnJlIHN1bnQgZWdhbGUKICAgICAgICBpZiAoYSA9PSBiKSB7CiAgICAgICAgICAgIGlmIChhID4gYykgewogICAgICAgICAgICAgICAgY291dCA8PCAoYSAtIGMgLSAxKSA8PCBlbmRsOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgY291dCA8PCAoYyAtIGEgLSAxKSA8PCBlbmRsOwogICAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChhID09IGMpIHsKICAgICAgICAgICAgaWYgKGEgPiBiKSB7CiAgICAgICAgICAgICAgICBjb3V0IDw8IChhIC0gYiAtIDEpIDw8IGVuZGw7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBjb3V0IDw8IChiIC0gYSAtIDEpIDw8IGVuZGw7CiAgICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgeyAvLyBiID09IGMKICAgICAgICAgICAgaWYgKGIgPiBhKSB7CiAgICAgICAgICAgICAgICBjb3V0IDw8IChiIC0gYSAtIDEpIDw8IGVuZGw7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBjb3V0IDw8IChhIC0gYiAtIDEpIDw8IGVuZGw7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9IGVsc2UgewogICAgICAgIC8vIFRvYXRlIHRyZWkgY2lmcmVsZSBzdW50IGRpZmVyaXRlCiAgICAgICAgaWYgKGEgPiBiICYmIGEgPiBjKSB7CiAgICAgICAgICAgIGlmIChiIDwgYykgewogICAgICAgICAgICAgICAgY291dCA8PCAoYSAtIGIgLSAyKSA8PCBlbmRsOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgY291dCA8PCAoYSAtIGMgLSAyKSA8PCBlbmRsOwogICAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChiID4gYSAmJiBiID4gYykgewogICAgICAgICAgICBpZiAoYSA8IGMpIHsKICAgICAgICAgICAgICAgIGNvdXQgPDwgKGIgLSBhIC0gMikgPDwgZW5kbDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGNvdXQgPDwgKGIgLSBjIC0gMikgPDwgZW5kbDsKICAgICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGlmIChhIDwgYikgewogICAgICAgICAgICAgICAgY291dCA8PCAoYyAtIGEgLSAyKSA8PCBlbmRsOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgY291dCA8PCAoYyAtIGIgLSAyKSA8PCBlbmRsOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIHJldHVybiAwOwp9