import java.io.*; import java.util.*; import java.util.stream.*; public class Main { static int db; static int b1000; static int b100; static int b1; static int dc; static int c1000; static int c100; static int c1; static HashMap dpb = new HashMap<>(); static HashMap dpc = new HashMap<>(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int a1000 = sc.nextInt(); int a100 = sc.nextInt(); int a1 = sc.nextInt(); db = sc.nextInt(); b1000 = sc.nextInt(); b100 = sc.nextInt(); b1 = sc.nextInt(); dc = sc.nextInt(); c1000 = sc.nextInt(); c100 = sc.nextInt(); c1 = sc.nextInt(); System.out.println(dfwb(a1000, a100, a1)); } static int dfwb(int x1000, int x100, int x1) { long key = getKey(x1000, x100, x1); if (!dpb.containsKey(key)) { int ans = dfwc(x1000, x100, x1); for (int i = 0; i <= x1000 && i * 1000 <= db; i++) { for (int j = 0; j <= x100 && j * 100 <= db - i * 1000; j++) { int value = db - i * 1000 - j * 100; if (x1 >= value) { ans = Math.max(ans, dfwb(x1000 - i + b1000, x100 - j + b100, x1 - value + b1) + 1); } } } dpb.put(key, ans); } return dpb.get(key); } static int dfwc(int x1000, int x100, int x1) { long key = getKey(x1000, x100, x1); if (!dpc.containsKey(key)) { int ans = 0; for (int i = 0; i <= x1000 && i * 1000 <= dc; i++) { for (int j = 0; j <= x100 && j * 100 <= dc - i * 1000; j++) { int value = dc - i * 1000 - j * 100; if (x1 >= value) { ans = Math.max(ans, dfwc(x1000 - i + c1000, x100 - j + c100, x1 - value + c1) + 1); } } } dpc.put(key, ans); } return dpc.get(key); } static long getKey(int x1000, int x100, int x1) { return x1000 * 100000000L + x100 * 100000L + x1; } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); 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 int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }