package no280; import java.util.Scanner; public class Main { public static long INF = 1L << 60L; 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(); } if (d == 0) { if (h[0] != h[1] && h[1] != h[2] && h[2] != h[0] && (h[1] > h[0] && h[1] > h[2]) || (h[1] < h[0] && h[1] < h[2])) { System.out.println(0); }else{ System.out.println(-1); } return; } int[] p = new int[3]; for(int i=0;i<3;i++) { p[i] = i; } long ans = INF; do { if (p[0] != 1 && p[2] != 1) { continue; } long count = 0; long x = h[p[0]]; for(int i=1;i<3;i++) { if (x == 0) { count = INF; break; } if (h[p[i]] >= x) { long magic = (h[p[i]] - x) / d + 1; count += magic; x = Math.max(0, h[p[i]] - magic * d); }else{ x = h[p[i]]; } } // System.out.println(Arrays.toString(p) + ":" + count); ans = Math.min(ans,count); } while(nextPermutation(p)); if (ans >= INF) { System.out.println(-1); }else{ System.out.println(ans); } } static boolean nextPermutation(int[] p) { for(int a=p.length-2;a>=0;--a) { if(p[a]p[a]) { int t = p[a]; p[a] = p[b]; p[b] = t; for(++a, b=p.length-1;a