import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static boolean is_valid_kadomatsu(long h1, long h2, long h3){ if(h1 == h2 || h2 == h3 || h3 == h1){ return false; } if(h1 < h2 && h2 > h3){ return true; }else if(h1 > h2 && h2 < h3){ return true; } return false; } public static int answer = 15; public static void dfs(int count, long d, long h1, long h2, long h3){ if(answer < count){ return; }else if(is_valid_kadomatsu(h1, h2, h3)){ answer = Math.min(answer, count); return; } if(h1 != 0){ dfs(count + 1, d, Math.max(0, h1 - d), h2, h3); } if(h3 != 0){ dfs(count + 1, d, h1, h2, Math.max(0, h3 - d)); } if(h2 != 0){ dfs(count + 1, d, h1, Math.max(0, h2 - d), h3); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final long d = sc.nextLong(); final long h1 = sc.nextLong(); final long h2 = sc.nextLong(); final long h3 = sc.nextLong(); dfs(0, d, h1, h2, h3); System.out.println(answer == 15 ? -1 : answer); } }