#include <iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main() {
int n, p, num,sum;
double min = 100000000;
int dai = 1;
cin >> num;
for (int i = 1; i < 4; i++) {
cin >> n >> p;
if (num % n != 0) dai = int (num / n )+ 1;
sum = dai * p;
if (sum < min)
min = sum;
}
cout << min;
return 0;
}