import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int[] sheets = new int[4]; for (int i = 0; i < 4; i++) { sheets[i] = sc.nextInt(); } int[] blocks = new int[3]; long ans = Long.MAX_VALUE; for (int a = 1; a <= 30; a++) { blocks[0] = a; for (int b = a + 1; b <= 30; b++) { blocks[1] = b; for (int c = b + 1; c <= 30; c++) { blocks[2] = c; long count = 0; int[] dp = new int[31]; for (int i = 0; i < 4; i++) { count += dfw(sheets[i], blocks, dp); } ans = Math.min(ans, count); } } } System.out.println(ans); } static int dfw(int x, int[] blocks, int[] dp) { if (x < 0) { return Integer.MAX_VALUE / 2; } if (x == 0) { return 0; } if (dp[x] == 0) { dp[x] = Integer.MAX_VALUE / 2; for (int i = 0; i < 3; i++) { dp[x] = Math.min(dp[x], dfw(x - blocks[i], blocks, dp) + 1); } } return dp[x]; } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }