#include<cmath>
#include<cstdio>
#include<algorithm>
int n,a,b,c,ans=2100000000,x,i;
int main()
{
scanf("%d",&n);
for (;i<3;i++)
{
scanf("%d%d",&a,&b);
x=std::ceil(n*1.0/a)*b;
ans=std::min(x,ans);
}
printf("%d\n",ans);
return 0;
}
#include<bits/stdc++.h>
using namespace std;
long n,a1,a2,b1,b2,c1,c2;
long pen1=0,pen2=0,pen3=0;
long x[3];
int main(){
cin>>n>>a1>>a2>>b1>>b2>>c1>>c2;;
while(pen1<n){
pen1+=a1;
x[0]+=a2;
}
while(pen2<n){
pen2+=b1;
x[1]+=b2;
}
while(pen3<n){
pen3+=c1;
x[2]+=c2;
}
sort(x,x+3);
cout<<x[0];
return 0;
}