#include using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int A[3], B, ans, maxa, maxc; cin >> A[0] >> A[1] >> A[2] >> B; maxc = A[0] + A[1] + A[2] + B; maxa = *max_element(A, A+3) * 3; ans = max(maxa, maxc); cout << ans << endl; return 0; }