#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 2000000000000000005

int main(){
	
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	cout<<max(c*3,a+b+c+d)<<endl;
	
    return 0;
}