import java.util.Scanner; public class Main_yukicoder281 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int d = sc.nextInt(); int[] h = new int[3]; for (int i = 0; i < 3; i++) { h[i] = sc.nextInt(); } int min = Integer.MAX_VALUE; if (d == 0) { if (h[1] > h[0] && h[1] > h[2] && h[0] != h[2]) { min = 0; } else if (h[1] < h[0] && h[1] < h[2] && h[0] != h[2]) { min = 0; } } else { int[] a = new int[3]; int[] tmp = new int[3]; for (int i = 0; i < 3; i++) { tmp[i] = h[i]; } a[0] = 1; a[1] = 2; a[2] = 0; int tmp2 = getCnt(a, d, tmp); if (tmp2 != -1) { min = Math.min(min, tmp2); } for (int i = 0; i < 3; i++) { tmp[i] = h[i]; } a[0] = 1; a[1] = 0; a[2] = 2; tmp2 = getCnt(a, d, tmp); if (tmp2 != -1) { min = Math.min(min, tmp2); } for (int i = 0; i < 3; i++) { tmp[i] = h[i]; } a[0] = 0; a[1] = 2; a[2] = 1; tmp2 = getCnt(a, d, tmp); if (tmp2 != -1) { min = Math.min(min, tmp2); } for (int i = 0; i < 3; i++) { tmp[i] = h[i]; } a[0] = 2; a[1] = 0; a[2] = 1; tmp2 = getCnt(a, d, tmp); if (tmp2 != -1) { min = Math.min(min, tmp2); } } if (min == Integer.MAX_VALUE) { System.out.println("-1"); } else { System.out.println(min); } sc.close(); } private static int getCnt(int[] a,int d, int[] h) { int tmp = 0; if (h[a[0]] == 0) { return -1; } if (h[a[0]] == h[a[1]]) { h[a[1]] = Math.max(0, h[a[1]] - d); tmp += 1; } else if (h[a[0]] < h[a[1]]) { int tmp2 = (h[a[1]] - h[a[0]] + d) / d; h[a[1]] = Math.max(0, h[a[1]] - tmp2 * d); tmp += tmp2; } if (h[a[1]] == 0) { return -1; } if (h[a[1]] == h[a[2]]) { h[a[2]] = Math.max(0, h[a[2]] - d); tmp += 1; } else if (h[a[1]] < h[a[2]]) { int tmp2 = (h[a[2]] - h[a[1]] + d) / d; h[a[2]] = Math.max(0, h[a[2]] - tmp2 * d); tmp += tmp2; } return tmp; } }