#include <bits/stdc++.h>
using namespace std;
long long d, k, a, b, t;
long long f(long long x) { return (k * (a - b) + t) * x + d * b - t; }
int main() {
  cin >> d >> k >> a >> b >> t;
  if (d <= k) {
    cout << d * a << endl;
  } else {
    long long lb = 1, ub = d / k;
    while (lb < ub) {
      long long x1 = lb + (ub - lb) / 3;
      long long x2 = ub - (ub - lb) / 3;
      long long f1 = f(x1), f2 = f(x2);
      if (f1 < f2)
        ub = x2 - 1;
      else
        lb = x1 + 1;
    }
    long long ans = min(f(lb), d * a + d / k * t);
    cout << ans << endl;
  }
  return 0;
}
