#include #define rep(i, a, n) for(int i = a; i < (n); i++) #define drep(i, a, n) for(int i = (n)-1; i >= a; i--) using namespace std; using ll = long long; using P = pair; const int INF = 1001001001; const ll LINF = 1001002003004005006ll; //const int mod = 1000000007; //const int mod = 998244353; int main() { int n = 3; vector a(n); rep(i, 0, n) cin >> a[i]; int b; cin >> b; int ans = 0; rep(i, 0, n) ans += a[i]; ans += b; sort(a.begin(), a.end()); ans = max(ans, 3*a[2]); cout << ans << endl; return 0; }