import java.util.Scanner; public class Yuki161{ public static void main(String[] arg){ Scanner sc = new Scanner(System.in); int[] me = new int[3]; int[] you = new int[3]; int res=0; me[0] = sc.nextInt(); me[1] = sc.nextInt(); me[2] = sc.nextInt(); String s = sc.next(); for(int i = 0;i= you[(i+1) % 3]){ res += you[(i+1) % 3] * 3; me[i] -= you[(i+1) % 3]; you[(i+1) % 3] = 0; }else{ res += me[i] * 3; you[(i+1) % 3] -= me[i]; me[i] = 0; } } for(int i = 0;i<3;i++){ if(me[i] >= you[i]){ res += you[i]; me[i] -= you[i]; you[i] = 0; }else{ res += me[i]; you[i] -= me[i]; me[i] = 0; } } System.out.println(res); } }