/** * @FileName a.cpp * @Author kanpurin * @Created 2022.10.17 02:34:36 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; constexpr long long LLINF = 1e18 + 1; int main() { int t;cin >> t; int x,a,y,b;cin >> x >> a >> y >> b; ll ans = LLINF; for (int i = 0; i <= 10000000; i++) { ll j = max(0LL,((ll)a*i-t+b-1)/b); ans = min(ans,(ll)(x-a)*i+(y+b)*j+t); } cout << ans << endl; return 0; }