#include using namespace std; int main() { int A, B, S, ans; cin >> A >> B >> S; if (abs(S - A) <= abs(S - B) || S == 1) { ans = abs(S - A) + abs(S); } else { ans = min(abs(S - B) + abs(S - A) + abs(A), abs(S - B) + abs(S - 1) + abs(A)); } cout << ans << endl; }