#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define INF 1000000000 using namespace std; typedef long long ll; int main(void) { int A, B, S; cin >> A >> B >> S; int ans = 0; if (S == 1) { ans += abs(S-A); ans += S; cout << ans << endl; return 0; } if (abs(S-B) < abs(S-A)) { ans += abs(S-B); ans += abs(S-A); ans += A; cout << ans << endl; } else { ans += abs(S-A); ans += S; cout << ans << endl; } return 0; }