using namespace std;
struct pencil {
int x, y, m;
} p[3];
bool cmp(pencil a, pencil b) {
return a.m < b.m;
}
int main() {
int n, b;
cin >> n;
for (int i = 0; i < 3; i++) {
cin >> p[i].x >> p[i].y;
b = (double)n / p[i].x + 0.9999999;
p[i].m = p[i].y * b;
}
sort(p, p + 3, cmp);
cout << p[0].m;
return 0;
}
比赛已结束。