#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(std::abs(s - a), s - 1) + a; } std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }