#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int A,B,C,D,E; cin >> A >> B >> C >> D >> E; int N = (B - C) * A; vector a; while(int(a.size()) < N) { if(a.empty()) a.push_back(D); else { int X = a.back(); if(int(a.size()) % 10 != 0) a.push_back(X); else { if(E <= X) a.push_back(X - E); else a.push_back(X); } } } cout << accumulate(a.begin(), a.end(), 0) << endl; }