#include<iostream>
#include<math.h>
using namespace std;
int main() {
int need, pencle, price,spend,max=99999;
cin >> need;
for (int i = 1;i < 4;i++)
{
cin >> pencle >> price;
if ((need, pencle, price) > 10000 && (need, pencle, price) < 1)
{
exit(1);
}
if (need%pencle == 0)
{
spend = need / pencle * price;
}
else
{
spend = (need / pencle+1) * price;
}
if (max > spend)
{
max = spend;
}
}
cout << max << endl;
system("pause");
return 0;
}