import java.util.*; public class Main { static int[] aArr = new int[4]; static int[] bArr = new int[4]; static HashMap>> dp = new HashMap<>(); public static void main (String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); for (int i = 0; i < 4; i++) { aArr[i] = sc.nextInt(); } for (int i = 0; i < 4; i++) { bArr[i] = sc.nextInt(); } System.out.println(func(a, b, c)); } static int func(int a, int b, int c) { int max = Math.max(func(a, b, c, aArr), func(a, b, c, bArr)); if (dp.containsKey(a)) { if (dp.get(a).containsKey(b)) { if (dp.get(a).get(b).containsKey(c)) { return dp.get(a).get(b).get(c); } } else { dp.get(a).put(b, new HashMap<>()); } } else { dp.put(a, new HashMap<>()); dp.get(a).put(b, new HashMap<>()); } dp.get(a).get(b).put(c, max); return max; } static int func(int a, int b, int c, int[] arr) { if (a * 1000 + b * 100 + c < arr[0]) { return 0; } int x = arr[0]; while (x >= 1000 && a > 0) { x -= 1000; a--; } while (x >= 100 && b > 0) { x -= 100; b--; } c -= x; if (c < 0) { return 0; } return func(a + arr[1], b + arr[2], c + arr[3]) + 1; } }