Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func main() {
	scanner.Split(bufio.ScanWords)

	n, _ := nextInt()
	a, _ := nextInt()
	b, _ := nextInt()
	c, _ := nextInt()
	d, _ := nextInt()

	costX := b * int(math.Ceil(float64(n)/float64(a)))
	costY := d * int(math.Ceil(float64(n)/float64(c)))
	fmt.Println(min(costX, costY))
}

C++: #include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  cout << min((n+a-1)/a * b, (n+c-1)/c * d) << endl;

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int sum,a,am,b,bm,x,y;
  cin>>sum;
  cin>>a>>am;
  cin>>b>>bm;
  if(sum%a==0){
    x=sum/a*am;
  }
  else{
    x=(sum/a+1)*am;
  }
  

  if(sum%b==0){
      y=sum/b*bm;
  }
  else{
    y=(sum/b+1)*bm;
  }
if(x>=y){
  cout<<y<<endl;
 }
 else{
   cout<<x<<endl;
 }


}

C++: #include<stdio.h>
int main(void)
{
	int n,x,y,a,b,c,d,x1,y1,x2,y2,l,f;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	x1=n/a;
	y1=n/c;
	l=n%a;
	f=n%c;
	if(l>=1){
		x1=x1+1;
	}
	if(f>=1){
		y1=y1+1;
	}
	x2=x1*b;
	y2=y1*d;
	if(x2<=y2){
		printf("%d\n",x2);
	}
	else if(y2<=x2){
		printf("%d\n",y2);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main() {
int N,A,B,C,D,E,F;
cin >> N >> A >> B >> C >> D;
   E = (N/A)*B;
   F = (N/C)*D;
   if(E>0&&F>0){
   if(A>C && B>D){
       cout<< E <<endl;
  } 
   if(A>C && B<D){
       cout<< E <<endl;
  } 
   if(A<C && B<D){
        cout<< F << endl;
  }
  if(A<C && B>D){
       cout<< F <<endl;
  } 
 
 }

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

int main()
{
  int n,a,b,c,d;
  int num1,num2;

  cin >> n >> a >> b >> c >> d;

  if(n % a == 0)
    {
      cout << (n/a)*b << endl;
    } 
  else if(n % c == 0)
    {
      cout << (n/c)*d << endl;
    }
  else
    {
      num1= (n/a)+1;
      num2= (n/c)+1;
      if(num1*b < num2*d)
	{
	  cout << num1*b << endl;
	}
      else
	{
	  cout << num2*d << endl;
	}
    }
}

C++: int main(){
    //test
    
}

C++: #include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n, a, b, c, d;
   cin >> n >> a >> b >> c >> d;

   cout << min((n+a-1)/a * b, (n+c-1)/c * d) << endl;

   return 0;
}

C++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0641


#include<iostream>
 using namespace std; //標準名前空間を使用

int main(){

    //変数を読み込む
    int N , A , B ,C ,D ;
    int Xset , Yset , Xprice , Yprice;

    // セットXで揃えた場合の必要セット数(Xset)を求める
    Xset = N / A + 1 ;
    // セットXで揃えた場合の合計金額を求める
    Xprice = Xset * B ;


    // セットYで揃えた場合のの必要セット数(Yset)を求める
    Yset = N / C + 1 ;
    // セットXで揃えた場合の合計金額を求める
    Yprice = Yset * D ;

    //XpriceとYpriceを比較する
    if(Xprice < Yprice){
    cout << Xprice ; //XpriceがYpriceより小さい場合、Xpriceを出力
    }else{
    cout << Yprice ; //そうでない場合、Ypriceを出力
    }

 return 0;

 }

C++: /////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  last updated: 2018-10-23 ...maybe
//
//    i hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -ddebug_local'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) reap(i,0,n)
#define reap(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__va_args__,reap,_rep,)(__va_args__)

#define _repr(i,n) reapr(i,n,0)
#define reapr(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define repr(...) _overload3(__va_args__,reapr,_repr,)(__va_args__)

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define coutall(a) {int loop_coutall=0;for(auto e:a) cout<<(loop_coutall++?" ":"")<<e; cout<<endl;}

#define coutyn(a) cout<<((a)?"yes":"no")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int inf=1145141919;
//const long long inf=114514191911451419;
const int mod=(int)1e9+7;
const double eps=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename t> istream &operator >> (istream &is, vector<t> &v){for(t &x:v) is>>x;return is;}
template<typename t> ostream &operator << (ostream &os, vector<t> &v){int i=0;for(t &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool ing(ll x,ll n){return 0<=x && 0<n;}
bool outg(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct arithmetic{arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define debug_local

#ifdef debug_local
template<typename t> void deb(t a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__line__<<"行目だ"<<endl;}
void what_cr(){cout<<__gcc_atomic_char16_t_lock_free<<" ←？"<<endl;}
//ori_func s

//ori_func e
#else
template<typename t>void deb(t a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  arithmetic exception;

  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;

  cout<<min(upper(n,a)*b,upper(n,c)*d)<<endl;

  return 0;

}