#!/usr/bin/python # -*- coding: utf-8 -*- # import from sys import stdin, setrecursionlimit setrecursionlimit(10**8) def int_map(): return map(int,input().split()) def int_list(): return list(map(int,input().split())) def int_mtx(N): x = [list(map(int, stdin.readline().split())) for _ in range(N)] return x def str_mtx(N): x = [list(stdin.readline()[:-1]) for _ in range(N)] return x def print_space(l): return print(" ".join([str(x) for x in l])) """ main code """ a1,a2,a3,b = int_map() if a1+a2+a3+b > 3*a3: print(a1+a2+a3+b) else: print(3*a3)