// https://www.luogu.com.cn/problem/P1909
#include <iostream>
using namespace std;
int main() {
int num, min, n, cost, a, i;
cin >> num;
for (i = 1; i <= 3; i++) {
cin >> n >> cost;
if (num % n) {
a = cost * (num / n + 1);
}
else {
a = cost * (num / n);
}
if (i == 1 || a < min) min = a;
}
cout << min;
return 0;
}