import java.util.Arrays; import java.util.Scanner; public class Yukicoder27 { static int[][] pat = {{0, 1, 2, 3}, {0, 1, 3, 2}, {0, 2, 3, 1}, {1, 2, 3, 0}}; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] V = new int[4]; for (int i = 0; i < 4; i++) V[i] = sc.nextInt(); Arrays.sort(V); int[] board = new int[3]; int min = Integer.MAX_VALUE; for (int i = 0; i < 4; i++) { board[0] = V[pat[i][0]]; board[1] = V[pat[i][1]]; board[2] = V[pat[i][2]]; for (int j = 0; j < 30; j++) { for (int k = 0; k < 30; k++) { for (int l = 0; l < 30; l++) { if (board[0] * j + board[1] * k + board[2] * l == V[pat[i][3]]) min = Math.min(min, j+k+l); } } } } System.out.println(min + 3); } }