#include <iostream>
#include <cmath>
using namespace std;
int main()
{
long double l, r, count, sum = 0,cyc;
int x, y, k;
cin >> l >> r >> x >> y >> k;
for (long long i = l; i <= r; i++)
{
count = i;
cyc = ceil(count / k);
for (long long j = 0; j < cyc; j++)
{
if (count > k)
{
sum += x * k;
sum += y;
}
else if (count <= k)
{
sum += count * x;
}
count -= k;
}
}
cout << sum;
}