#include #define rep(i, l, n) for (int i = (l); i < (n); i++) using namespace std; int main(void) { int a1, a2, a3, b; cin >> a1 >> a2 >> a3 >> b; int a[3] = { a1,a2,a3 }; int ans = 0; rep(i, 0, 3) { rep(j, 0, 3) { rep(k, 0, 3) { int damage = a[i] + a[j] + a[k]; if (i == 0 and j == 1 and k == 2) { damage += b; } ans = max(ans, damage); } } } cout << ans << endl; return 0; }