#include #include void solve() { int a, b, s; std::cin >> a >> b >> s; int ans; if (std::abs(a - s) <= std::abs(b - s) || s == 1) { ans = std::abs(a - s) + s; } else { ans = std::abs(b - s) + std::min(a > 0 ? std::abs(s - a) : 100, s - 1) + a; } std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }