#include using namespace std; #define rep(i, n) for(int i = 0; i < int(n); i++) using ll = long long; using P = pair; int main() { cin.tie(0); ios_base::sync_with_stdio(false); int a, b, c, d, e; cin >> a >> b >> c >> d >> e; int kosuu = (b - c) * a; int ans = 0; int cost = -1; rep(i, kosuu) { if(i == 0) cost = d; else if (i % 10 == 9 && e <= cost) cost -= e; ans += cost; } cout << ans << endl; return 0; }