#include<iostream> using namespace std; int main() { long n,min,w,i,x,y; min=1000000000; cin>>n; for (i=1;i<=3;i++) { cin>>x>>y; if (n%x==0) w=n/x*y; else w=(n/x+1)*y; if (w<min) min=w; } cout<<min; return 0; }