#include <bits/stdc++.h>
using namespace std;
long long k, a, b, t, d, setk;
long long f(long long x) {
  long long p;
  if (x * k > d) {
    p = setk * a * k + (setk - 1) * t;
    if (d % k != 0) p += (d % k) * a + t;
    return p;
  }
  if (x == 0) return d * b;
  p = x * k * a + (x - 1) * t + (d - x * k) * b;
  return p;
}
int main() {
  long long lo, hi, i, m1, m2;
  cin >> d >> k >> a >> b >> t;
  if (d <= k)
    cout << a * d << endl;
  else {
    setk = d / k;
    lo = 0, hi = (d / k + 1);
    for (i = 0; i < 150; i++) {
      m1 = lo + (hi - lo) / 3;
      m2 = hi - (hi - lo) / 3;
      if (f(m1) > f(m2))
        lo = m1;
      else
        hi = m2;
    }
    long long ans = min(f(m1), min(f(m2), f(m1 + 1)));
    cout << ans << endl;
  }
}
