import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int[] ita = new int[4]; for (int i = 0; i < 4; i++) { ita[i] = sc.nextInt(); } int ans = Integer.MAX_VALUE; for (int i = 1; i <= 30; i++) { for (int j = i + 1; j <= 30; j++) { for (int k = j + 1; k <= 30; k++) { int sum = 0; int[] dp = new int[31]; int[] piece = new int[]{i, j, k}; for (int l = 0; l < 4; l++) { sum += dfw(ita[l], piece, dp); } ans = Math.min(ans, sum); } } } System.out.println(ans); } static int dfw(int size, int[] piece, int[] dp) { if (size < 0) { return 40; } if (size == 0) { return 0; } if (dp[size] == 0) { dp[size] = Integer.MAX_VALUE; for (int x : piece) { dp[size] = Math.min(dp[size], dfw(size - x, piece, dp) + 1); } } return dp[size]; } } 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 nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }