#include<stdio.h>
int main(void){
int n1,n2,n3,price1,price2,price3,money1,money2,money3,number,count1,count2,count3,remainder1,remainder2,remainder3,max;
scanf("%d",&number);
scanf("%d%d\n",&n1,&price1);
scanf("%d%d\n",&n2,&price2);
scanf("%d%d\n",&n3,&price3);
remainder1=number%n1;
remainder2=number%n2;
remainder3=number%n3;
count1=number/n1;
count2=number/n2;
count3=number/n3;
if(remainder1==0){
money1=count1*price1;
if(remainder1!=0){
count1=count1+1;
money1=count1*price1;
}
}
if(remainder2==0){
money2=count2*price2;
if(remainder2!=0){
count2=count2+1;
money2=count2*price2;
}
}
if(remainder3==0){
money3=count3*price3;
if(remainder3!=0){
count3=count3+1;
money3=count3*price3;
}
}
if(money1>money3){
if(money1>money2){
max=money1;
}
else{
max=money2;
}
}
else{
if(money3>money2){
max=money3;
}
else{
max=money2;
}
}
printf("%d",max);
return 0;
}