#include <bits/stdc++.h>
using namespace std;
int main()
{
double a,x1,x2,y1,y2,z1,z2,b,x3,y3,z3,c;
cin>>a;
cin>>x1>>x2;
cin>>y1>>y2;
cin>>z1>>z2;
x3=ceil(a/x1)*x2;
y3=ceil(a/y1)*y2;
z3=ceil(a/z1)*z2;
if(x3<y3&&x3<z3)
{
c=x3;
}
if(y3<x3&&y3<z3)
{
c=y3;
}
if(z3<x3&&z3<y3)
{
c=z3;
}
cout<<c<<endl;
return 0;
}