#include using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int a,b,c,d,e; cin >> a >> b >> c >> d >> e; int want=(b-c)*a; int res=0; int past=-1; for(int i=1;i<=want;i++){ if(past<0){ past=d; res+=past; } else{ if(i%10!=0){ res+=past; } else{ if(e<=past){ past-=e; res+=past; } else{ res+=past; } } } } printf("%d\n",res); }