import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	void run() {
		Scanner sc=new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int[] A=new int[3];
		int[] B=new int[3];
		int[] C=new int[3];
		int[] D=new int[2];
		int[][] E=new int[2][3];
		for (int i=0;i<3;++i) A[i]=sc.nextInt();
		D[0]=sc.nextInt();
		for (int i=0;i<3;++i) E[0][i]=sc.nextInt();
		D[1]=sc.nextInt();
		for (int i=0;i<3;++i) E[1][i]=sc.nextInt();
		int[][][] dp=new int[11][101][10001];
		int INF=Integer.MAX_VALUE/3;
		for (int i=0;i<dp.length;++i)
			for (int j=0;j<dp[i].length;++j)
				for (int k=0;k<dp[i][j].length;++k)
					dp[i][j][k]=-INF;
		dp[A[0]][A[1]][A[2]]=0;
		for (int sum=10000;sum>=1;--sum) {
			for (int c1000=0;1000*c1000<=sum;++c1000) {
				for (int c100=0;1000*c1000+100*c100<=sum;++c100) {
					for (int i=0;i<2;++i) {
						int c1=sum-1000*c1000-100*c100;
						if (dp[c1000][c100][c1]<0) continue;
						int res=D[i];
						int q1000=Math.min(c1000, res/1000);
						res-=q1000*1000;
						int q100=Math.min(c100, res/100);
						res-=q100*100;
						int q1=Math.min(c1, res);
						res-=q1*1;
						if (res==0) {
							int nc1000=c1000-q1000+E[i][0];
							int nc100=c100-q100+E[i][1];
							int nc1=c1-q1+E[i][2];
							dp[nc1000][nc100][nc1]=Math.max(dp[nc1000][nc100][nc1], dp[c1000][c100][c1]+1);
						}
					}
				}
			}
		}
		int ans=0;
		for (int i=0;i<dp.length;++i)
			for (int j=0;j<dp[i].length;++j)
				for (int k=0;k<dp[i][j].length;++k)
					ans=Math.max(ans, dp[i][j][k]);
		pw.println(ans);
		pw.close();
	} 
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
	
    public static void main(String[] args) {
    	new Main().run();
    }
}