Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	scanner.Split(bufio.ScanWords)

	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()
	p := nextInt()

	priceA := a * p
	priceB := 0
	if p <= c {
		priceB = b
	} else {
		priceB = b + (p-c)*d
	}
	fmt.Println(min(priceA, priceB))
}

C++: #include<iostream>
#include<string>
using namespace std;

int main(){
	/*
	int a,b,c,d,e;

	cin >> a >> b >> c >> d >> e;

	int x;

	if(a > 0){
		x = e*(b-a);
	}
	if(a == 0){
		x = e*b + d;
	}
	if(a < 0){
		x = -c*a + e*b + d;
	}

	cout << x <<endl;
	*/

	/*
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;
	int m,n;
	int x = a + b + c + d + e + f;


	
	if(e<f)
	{
		x = x - e;
		if(a<b)
		{
			if(a<c)
			{
				if(a<d)
				{
					cout << x-a << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
		else
		{
			if(b<c)
			{
				if(b<d)
				{
					cout << x-b << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
	}
	else
	{
		x = x - f;
		if(a<b)
		{
			if(a<c)
			{
				if(a<d)
				{
					cout << x-a << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
		else
		{
			if(b<c)
			{
				if(b<d)
				{
					cout << x-b << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
	}
	*/
/*
	int n;
	cin >> n;
	int a;
	cin >> a;
	int max = a,min = a;
	int i = 1;
	while(i<n){
		cin >> a;
		if(a > max){
			max = a;
		}
		if(a < min){
			min = a;
		}
		i++;
	}
	cout << max << endl << min << endl;
	*/
	/*
	string s;
	cin >> s;
	int j,o,i;
	for(int i;i < s.size;i++){
		
	}
	*/
	/*
	int n;
	cin >> n;
	int A;
	int X[100000];
	int n=0;
	for(int i=0;i<n;i++){
		cin >> A;
		
	}
	*/
	/*
	int a,b,c,d,p;
	cin >> a >> b >> c >> d >> p;
	int X,Y=b;

	X = a*p;
	
	if(p>c){
		Y += d*(p-c);
	}

	if(X > Y){
		cout << Y << endl;
	}
	else{
		cout << X << endl;
	}
	*/

	int l,a,b,c,d;
	cin >> l >> a >> b >> c >> d;
	int day;

	if(a/c > b/d){
		day = a/c;
	}else{
		day = b/d;
	}

	cout << l - day << endl;

	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <cstdio>
#include <float.h>
#include <ctype.h>
 using namespace std;
 int main(void) {
        int a, b, c, d, e, f, g, h, i, j, k, l, m, o, p, q, r, s, t, u, v, w, x, y, z;
        scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
        f = a * e;
        if (e<=c) {
            g = b;
        }
        else {
            h = e - c;
            g = h*d+b;
        }
        if (f < g) {
            printf("%d\n", f);
        }
        else if(g<f){
            printf("%d\n", g);
        }
        return 0;
 }

C++: #include<stdio.h>
int main(void)
{
	int a,b,c,d,e,x,X,i;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	X=a*e;
	if(e<=c){
		x=b;
	}
	else{
		x=b;
		e-=c;
		x+=e*d;
	}
	if(X<x){
		printf("%d\n",X);
	}
	else{
		printf("%d\n",x);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int a, b, c, d, p, X, Y;
	cin >> a >> b >> c >> d >> p;
		X = a*p;
		if (p <= c){
			Y = b;
		}
		else{
			p - c;
			Y = c*d + b;
		}

		if (Y < X){
			cout << Y << endl;
		}
		else{
			cout << X << endl;
		}





	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int a,b,c,d,p,x,y;
	cin >> a >> b >> c >> d >> p;
	x=a*p;
	if(p<=c){
		y=b*p;
	}else if(p>c){
		y=b*p+(p-c)*d;
	}
	if(x>y){
		cout << y << endl;
	}else {
		cout << x << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
    int a, b, c, d, p, t, h;
    cin >> a >> b >> c >> d >> p;
    t = a * p;
    h = b + (p>c?p-c:0) * d;
    if(t<h) cout << t;
    else cout << h << endl;
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int A, B, C, D, P;
int main() {
  cin >> A >> B >> C >> D >> P;
  cout << min(A*P, B + (P<C ? 0 : (P-C)*D)) << "\n";
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define first F
#define second S

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int a,b,c,d,p;
  cin>>a;
  cin>>b;
  cin>>c;
  cin>>d;
  cin>>p;
  cout<<min(p*a,max(0,b+(p-c)*d))<<endl;
}

C++: #include<stdio.h>
int main(){
	int a,b,c,d,p,x,y,r;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);
	if(c>p){
		y=b;
	}else{
		y=b+(p-c)*d;
	}
	x=a*p;
	if(y<x){
		r=y;
	}else{
		r=x;
	}
	printf("%d\n",r);
	return 0;
}

C++: #include  <iostream>

using namespace std;

int main()
{
	int x, y1, y2, y3, joi;
	int resx, resy;
	
	cin >> x;
	cin >> y1;
	cin >> y2;
	cin >> y3;
	cin >> joi;
	
	resx = x * joi;
	resy = y1 + (joi > y2 ? joi - y2 : 0) * y3;
	
	cout << (resx < resy ? resx : resy) << endl;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
int a,b,c,d,p,x,y,ans;
cin >> a >> b >> c >> d >>p;
ans=min(a*p,b+(p-c)*(c<p ?d:0));
cout << ans << endl;
return 0;
}

C++: #include <cstdio>
using namespace std;

int main()
{
	int a, b, c, d, p;
	
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &p);
	
	a *= p;
	
	if (p > c){
		b += d * (p - c);
	}
	
	if (a < b){
		printf("%d\n", a);
	}
	
	else {
		printf("%d\n", b);
	}
	
	return (0);
}

C++: #include <iostream>

using namespace std;

int main(){

	int a , b , c , d;
	int p;

	cin >> a >> b >> c >> d >> p;

	int A = a * p;
	int l = p - c;

	if(c > p){
		if(b < A){
			cout << b << endl;
		}
		else{
			cout << A << endl;
		}
	}
	else if(c < p){
		int ans = b + (d * l);
		if(ans < A) cout << ans << endl;
		else cout << A << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;

int main() {
	int a,b,c,d,p;
	cin >> a >> b >> c >> d >> p;
	if(p<c){
		if(a*p<b){
			cout << a*p << endl;; 
		}else{
			cout << b << endl;
		}
	}else{
		if(a*p<b+(p-c)*d){
			cout << a*p << endl;
		}else{
			cout << b+(p-c)*d << endl;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int a, b, c, d, p;
	int cmp[2] = {0};

	cin >> a >> b >> c >> d >> p;

	cmp[0] = a * p;
	cmp[1] = b;

	if (c < p){
		p -= c;
		cmp[1] += (p * d);
	}

	if (cmp[0] < cmp[1]){
		cout << cmp[0] << endl;
	}
	else {
		cout << cmp[1] << endl;
	}

	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a,b,c,d,e,w,x,z,y;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	w=a*e;
	z=(e-c)*d;
	if(e<=c){
		x=b;
	}
	else{
		x=z+b;
	}
	if(w<x){
		printf("%d\n",w);
	}
	else{
		printf("%d\n",x);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e;
int main() {
	cin >> a >> b >> c >> d >> e;
	cout << min(a * e, max(b, b + (e - c) * d)) << endl;
	return 0;
}