#include using namespace std; int dp[105]; int main() { int A,B,C,D,E; cin >> A >> B >> C >> D >> E; B -= C; dp[1] = D; for(int i = 2; i <= A; i++) { if(i%10 != 0) { dp[i] = dp[i-1]; } else if(E <= dp[i-1]) { dp[i] = dp[i-1]-E; } else { dp[i] = dp[i-1]; } } int ans = 0; for(int i = 1; i <= A; i++) { ans += dp[i]; } cout << ans*B << endl; }