import java.util.*; public class Main { static int[] aArr = new int[4]; static int[] bArr = new int[4]; 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) { return Math.max(func(a, b, c, aArr), func(a, b, c, bArr)); } 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; } }