#include #include int main() { int gx, gy, ex, ey; std::cin >> gx >> gy >> ex >> ey; int ans = 0; if (ex == ey){ if (gx > gy) { gx -= 1; } else { gy -= 1; } ans++; } if (gx > gy) { gx -= gy; ex -= gy; ey -= gy; ans += gy; gy = 0; } else { gy -= gx; ey -= gx; ex -= gx; ans += gx; gx = 0; } ans += std::max(gx, gy); if (ey < 0 || ex < 0) { std::cout << ans << std::endl; return 0; } std::cout << ans << std::endl; return 0; }