def main(): a, b, c, d = map(int, input().split()) print(max(a+b+c+d, 3*c)) if __name__ == '__main__': main()