#pragma comment(linker, "/STACK:268435456")

//#include "testlib.h"
//#include "problib.h"

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <sstream>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <iomanip>
#include <bitset>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
typedef unsigned int uint;

#define mp make_pair
#define sqr(a) ((a)*(a))
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define forr(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define forit(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()

#define MIN(a, b) ((a)<(b)?(a):(b))
#define MAX(a, b) ((a)>(b)?(a):(b))

typedef vector<int> vint;
typedef vector<bool> vbool;
typedef vector<int64> vint64;
typedef vector<uint64> uvint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;

template<typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p)
{
	in >> p.first >> p.second;
	return in;
}
template<typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p)
{
	out << p.first << " " << p.second;
	return out;
}
template<typename T>
istream& operator >> (istream& in, vector<T>& v)
{
	forn(i, v.size())
	{
		in >> v[i];
	}
	return in;
}
template<typename T>
ostream& operator << (ostream& out, vector<T>& v)
{
	forn(i, v.size())
	{
		out << v[i] << ' ';
	}
	return out;
}

struct FT
{
	vint64 t;
	int sz;

	void init(int n)
	{
		sz = n;
		t.assign(sz, 0);
	}

	void inc(int i)
	{
		for (; i < sz; i = (i | (i + 1)))
			t[i] += 1;
	}

	int64 sum(int r)
	{
		int64 res = 0;
		for (; r >= 0; r = (r & (r + 1)) - 1)
			res += t[r];
		return res;
	}

	int64 sum(int l, int r)
	{
		return sum(r) - sum(l - 1);
	}
};

const int64 INF = 1e18;

struct MyInt
{
	int64 i;

	MyInt(int64 i)
		:i(i)
	{}

	MyInt()
		:i(INF)
	{}

	friend const bool operator<(const MyInt& a, const MyInt& b)
	{
		return a.i > b.i;
	}
};

const int MAXN = 5005;

vector<map<pii64, int64>> g;

struct State
{
	int h;
	int64 t;
	int q;

	State(int h, int64 t, int q)
		:h(h), t(t), q(q)
	{}

	friend const bool operator<(const State& a, const State& b)
	{
		return a.t > b.t;
	}
};

int main(int argc, char* argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

#ifdef LYZ_V
	freopen("ReadMe.txt", "r", stdin);
	//freopen("ReadMe.txt", "w", stdout);
#else
	//freopen("jenga.in", "r", stdin);
	//freopen("jenga.out", "w", stdout);
#endif

	int64 p1, t1;
	int64 p2, t2;
	int64 h, s;

	cin >> p1 >> t1;
	cin >> p2 >> t2;
	cin >> h >> s;

	if (t1 < t2)
	{
		swap(t1, t2);
		swap(p1, p2);
	}
	g.resize(h + 1);

	pii64 t12 = mp(t1, t2);

	g[h][t12] = 0;
	int64 res = INF;

	for (; h > 0; --h)
	{
		for (auto it = g[h].begin(); it != g[h].end(); ++it)
		{
			int64 nt = it->second + it->first.first;
			int nh = max(0ll, h - (p1 - s));
			int64 nr = max(0ll, it->first.second - it->first.first);
			if (nh == 0)
				res = min(res, nt);
			pii64 ntp = mp(t1, nr);
			auto nit = g[nh].find(ntp);
			if (nr > 0 && nt < res && it->first.second < t2 * 2)
			{
				if (nit != g[nh].end())
					g[nh][ntp] = min(nit->second, nt);
				else
					g[nh][ntp] = nt;
			}

			nt = it->second + it->first.second;
			nh = max(0ll, h - (p2 - s));
			nr = max(0ll, it->first.first - it->first.second);
			if (nh == 0)
				res = min(res, nt);
			ntp = mp(nr, t2);
			nit = g[nh].find(ntp);
			if (nr > 0 && nt < res && it->first.second < t1 * 2)
			{
				if (nit != g[nh].end())
					g[nh][ntp] = min(nit->second, nt);
				else
					g[nh][ntp] = nt;
			}

			nt = it->second + max(it->first.second, it->first.first);
			nh = max(0ll, h - (p2 + p1 - s));
			if (nh == 0)
				res = min(res, nt);
			nit = g[nh].find(t12);
			if (nt < res && it->first.first < t2 * 2)
			{
				if (nit != g[nh].end())
					g[nh][t12] = min(nit->second, nt);
				else
					g[nh][t12] = nt;
			}
		}
		g[h].clear();
	}

	cout << res << endl;

	return 0;
}

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> PII;
typedef std::pair<ll, ll> PLL;
typedef double db;
#define re _read
#define ALL(x) (x).begin(),(x).end()
#define SZ(v) ((int)v.size())
#define fi first
#define se second
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl "\n"
using namespace std;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x;}
template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) { out << "["; bool first = true; for (auto &&e : v) { if (first) { first = false;} else {out << ", ";} out << e; } return out << "]"; }
template <typename A, typename B> std::ostream &operator<<(std::ostream &out, const std::pair<A, B> &v) {  return out << "(" << v.first << ", " << v.second << ")"; }
template <typename K> std::ostream &operator<<(std::ostream &out, const std::set<K> &s) {  out << "{"; bool first = true; for (auto &&k : s) { if (first) { first = false; } else { out << ", "; } out << k; } return out << "}"; }
template <typename K, typename V> std::ostream &operator<<(std::ostream &out, const std::map<K, V> &m) { out << "{"; bool first = true; for (auto &&[k, v] : m) { if (first) { first = false; } else { out << ", "; } out << k << ": " << v; } return out << "}"; }
template <class T> vector<vector<T>> Vector(int n, int m) { return vector<vector<T>> (n, vector<T> (m, 0)); }
template <class T> vector<vector<vector<T>>> Vector(int i, int j, int k) { return vector<vector<vector<T>>> (i, vector<vector<T>>(j, vector<T>(k, 0))); }
template <typename T> void OUT(T* a, int l, int r) { for (int i = l; i <= r; i ++) cout << a[i] << " "; puts(""); }
template<class T>
inline void _read(T& x) {
    static T ans;
    static unsigned int c;
    static bool p;
    for (c = getchar(); c != '-' && (c < '0' || c > '9'); c = getchar());
    if (c == '-') p = false, c = getchar(); else p = true;
    for (ans = 0; c <= '9' && c >= '0'; c = getchar()) ans = ans * 10 + c - '0';
    x = p ? ans : -ans;
}
/*----------------------------------------------------------------------------------------------------*/
ll p1, t1, p2, t2, h, s;
const int N = 5010;
ll f[N];

int main() {
    // freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
    int T;
    re(p1), re(t1), re(p2), re(t2);
    re(h), re(s);
    ll dam1 = p1 - s, dam2 = p2 - s, dam12 = p1 + p2 - s;
    for (int i = 1; i <= h; i++) {
        f[i] = min(f[max(0ll, i - dam1)] + t1, f[max(0ll, i - dam2)] + t2);
        for (int j = 1; j <= i; j++) {
            if (j * t1 >= t2) {
                ll dmg = (j - 1) * dam1 + (t1 * j - t2) / t2 * dam2 + dam12;
                f[i] = min(f[i], f[max(0ll, i - dmg)] + j * t1);
            }
            if (j * t2 >= t1) {
                ll dmg = (j - 1) * dam2 + (t2 * j - t1) / t1 * dam1 + dam12;
                f[i] = min(f[i], f[max(0ll, i - dmg)] + j * t2);
            }
        }
    }
    printf("%lld\n", f[h]);
    // fclose(stdin);
    // fclose(stdout);
    return 0;
}

#include <bits/stdc++.h>
#define sz(n) (int)(n).size()

using namespace std;

typedef long long ll;
const ll INF = 1e18 + 73;

void solve() {
    ll p1, t1, p2, t2, h, s;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
    vector<ll> dp(h + 1, INF);
    dp[0] = 0;
    for (ll h1 = 0; h1 < h; ++h1) {
        if (dp[h1] == INF) continue;
        dp[min(h, h1 + p1 + p2 - s)] = min(dp[min(h, h1 + p1 + p2 - s)], dp[h1] + max(t1, t2));
        for (ll cur_h = h1, cur_t = dp[h1], l1 = cur_t, l2 = cur_t; cur_h < h; ) {
            if (t1 + l1 < t2 + l2) {
                cur_t = t1 + l1;
                cur_h += p1 - s;
                l1 = cur_t;
            } else {
                cur_t = t2 + l2;
                cur_h += p2 - s;
                l2 = cur_t;
            }
            if (cur_h >= h) dp[h] = min(dp[h], cur_t);
            dp[min(h, cur_h + p1 + p2 - s)] = min(dp[min(h, cur_h + p1 + p2 - s)], max(t1 + l1, t2 + l2));
        }
    }
    cout << dp[h] << '\n';
}

int main() {
#ifdef LOCAL
    freopen("../stream.in", "r", stdin);
    freopen("../stream.out", "w", stdout);
#else
    cin.tie(nullptr)->sync_with_stdio(false);
#endif
    solve();
    return 0;
}

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC optimization("O3")
using namespace std;
///Macros
#define int long long
#define it(x) x::iterator
#define pb push_back
#define pf push_front
#define lb lower_bound
#define up upper_bound
#define fs first
#define sc second
#define endl '\n'
#define pf push_front
#define all(x) x.begin() , x.end()
#define sz(x) (int)(x.size())
#define eps 1e-12
#define FOR(i,a,n) for(int i=a;i<(n);i++)
#define FO(i,n) for(int i=0;i<(n);i++)
#define RFOR(i,a,n) for(int i=(n)-1;i>=a;i--)
#define RFO(i,n) for(int i=(n)-1;i>=0;i--)
#define gof(i,n) for(auto &i: n);

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector< ii > vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef pair<vi,vi> pvv;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

///Constraints:
const int inf = ((1ll<<31ll)-1ll);
const int INF = (((1ll<<60ll)-1ll)*2ll)+1ll;
const ull mod = INF;
const ld pi = acos(-1);
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lg2ll(x) 63 - __builtin_clzll(x)
#define lgx(x,b) ( log(x) / log(b) )
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/*void print(vector<int>v){for(auto that:v)cout<<that<<" ";cout<<endl;}
vector<int>read(int cnt){vi v(cnt);for(int i=0;i<cnt;i++)cin>>v[i];return v;}*/

/*#include<ext/pb_ds/assoc_container.hpp> // Common file
#include<ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
//comenta el define long long int
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
// find_by_order
// order_of_key
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
/// Quick Pow------------------------------------------------
int qpow(ull b,int e)
{
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b %mod ;
    int pwur = qpow(b,e>>1);
    return pwur * pwur %mod;
}
///Inverso Modular
int InverM(int a,int b)
{
    cout<<a<<' '<<b<<endl;
    int eso=a-(a/b)*b;
    if(eso==0)
        return 0;
    int ans=(1-b*InverM(b,eso))/eso;
    if(ans<0)
        ans+=b;
    return ans;

}
const int MAXN=100004;
/// Variables------------------------------------------------
int n,m,k,q;
void problem()
{
    int p1,p2,t1,t2,h,s;
    cin>>p1>>t1;
    cin>>p2>>t2;
    cin>>h>>s;
    vii DP;
    DP.pb({0,0});
    vii DP2;
   int curD=0,T1=t1,T2=t2;
   while(curD<h){
   if(T1<T2){
   curD+=p1-s;
   DP.pb({curD,T1});
   DP2.pb({curD+p2,T2});
   T1+=t1;
   }
   if(T1>T2){
   curD+=p2-s;
   DP.pb({curD,T2});
   DP2.pb({curD+p1,T1});
   T2+=t2;
   }
   if(T1==T2){
   DP2.pb({curD+p1+p2-s,T1});
   break;
   }
   }
   sort(all(DP2));
   vi dp(10001,INF);
   dp[0]=0;
   for(int i=1;i<=10000;i++){
     for(int j=0;j<sz(DP2);j++){
     if(i-DP2[j].fs<0)
     break;
     if(dp[i-DP2[j].fs]!=INF){
     dp[i]=min(dp[i],dp[i-DP2[j].fs]+DP2[j].sc);
     }
     }
   }

   int ans=INF;
   for(int i=0;i<=10000;i++){
       for(int j=0;j<sz(DP);j++){
         if(i+DP[j].fs>=h){
            ans=min(ans,dp[i]+DP[j].sc);
         }
       }
   }
   cout<<ans;

}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);

    // freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int tc=1;
   // cin>>tc;
    while(tc--)
    {
        problem();
        cout<<endl;
    }

}

///Tips
//Busqueda Binaria
//Precomputing
//Dinamic Programming
//Revisar constraints

#include<bits/stdc++.h>
#define up(i, a, b) for(int i = (int)a; i <= (int)b; ++i)
#define dn(i, a, b) for(int i = (int)a; i >= (int)b; --i)
#define vc vector
#define pb push_back
#define pii pair<int, int>
#define mpr make_pair
#define x first
#define y second
#define int long long

using namespace std;

const int MN = 5005;

int p1, t1, p2, t2;

int h, s;
int f[MN];

signed main(){
	up(i, 0, 5000) f[i] = 1e18;
	scanf("%lld%lld%lld%lld%lld%lld", &p1, &t1, &p2, &t2, &h, &s);
	f[0] = 0;
	up(i, 1, h){
		up(j, 1, h){
			f[i] = min(f[i], f[max(i - j * (p1 - s) - j * t1 / t2 * (p2 - s), 0ll)] + j * t1);
			f[i] = min(f[i], f[max(i - j * (p2 - s) - j * t2 / t1 * (p1 - s), 0ll)] + j * t2);
			if(j * t1 >= t2)f[i] = min(f[i], f[max(i - (j - 1) * (p1 - s) - (j * t1 / t2 - 1) * (p2 - s) - p1 - p2 + s, 0ll)] + j * t1);
			if(j * t2 >= t1)f[i] = min(f[i], f[max(i - (j - 1) * (p2 - s) - (j * t2 / t1 - 1) * (p1 - s) - p1 - p2 + s, 0ll)] + j * t2);
		}
	}
	printf("%lld\n", f[h]);

	return 0;
}

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

#define ll long long
#define pi pair<ll,ll>
const int N=5e3+100;

ll h,s,ans=1e18;
ll p1,p2,t1,t2;
ll dp[N];

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>p1>>t1;
	cin>>p2>>t2;
	cin>>h>>s;
	for(int i=0;i<=h;i++) dp[i]=1e18;
	dp[0] = 0;
	for (ll i = 0; i < h; i++)
	{
		if(p1>s) dp[min(h, i+p1-s)] = min(dp[min(h, i+p1-s)], dp[i]+t1);
		if(p2>s) dp[min(h, i+p2-s)] = min(dp[min(h, i+p2-s)], dp[i]+t2);
		for(int j=1;j<=h;j++) {
			if(j*t1>=t2) {
				ll d = (j-1)*(p1-s) + ((j*t1-t2)/t2)*(p2-s) + (p1+p2-s);
				if(d>0) dp[min(h, i+d)] = min(dp[min(h, i+d)], dp[i]+j*t1);
			}
			if(j*t2>=t1) {
				ll d = (j-1)*(p2-s) + ((j*t2-t1)/t1)*(p1-s) + (p1+p2-s);
				if(d>0) dp[min(h, i+d)] = min(dp[min(h, i+d)], dp[i]+j*t2);
			}
		}
	}
	cout<<dp[h]<<"\n";

	return 0;
}

// CAUTION REVIEW

#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;++a)
#define per(a,b,c) for(int a=b;a>=c;--a)
#define ll long long
using namespace std;
#define int ll
const int N=5010;
ll dp[N],t[2];
int p[2],h,s;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	cin>>p[0]>>t[0]>>p[1]>>t[1]>>h>>s;

	memset(dp,0x3f,sizeof dp);
	dp[0]=0;
	rep(i,0,h-1)rep(j,0,h-i)rep(k,0,1)
	{
		int to=i+j*(p[k]-s)+j*t[k]/t[k^1]*(p[k^1]-s);
		to=min(to,h);
		dp[to]=min(dp[i]+j*t[k],dp[to]);
		to=i+(j-1)*(p[k]-s)+(j*t[k]/t[k^1]-1)*(p[k^1]-s)+(p[k]+p[k^1]-s);
		to=min(to,h);
		if(j*t[k]/t[k^1]-1>=0)dp[to]=min(dp[i]+j*t[k],dp[to]);
	}

	// rep(i,1,h)cerr<<dp[i]<<' ';
	// cerr<<endl;

	cout<<dp[h]<<endl;

	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <queue>
#include <climits>

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
template<class T>bool umin(T& a,const T& b){return b<a ? a=b,1:0;}
template<class T>bool umax(T& a,const T& b){return a<b ? a=b,1:0;}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll p[2], t[2], h, s;
    cin >> p[0] >> t[0] >> p[1] >> t[1] >> h >> s;
    vector<pll> a;
    if(t[0] < t[1]) swap(p[0], p[1]), swap(t[0], t[1]);
    a.push_back({p[0] - s, t[0]});
    a.push_back({p[1] - s, t[1]});
    ll comb = -1;
    for(int i = 1; comb < h; ++i){
        ll cnt1 = t[0] * i / t[1];
        comb = (p[0] - s) * i + (p[1] - s) * cnt1 + s;
        a.push_back({comb, t[0] * i});
        a.push_back({comb + p[1] - s, t[1] * (cnt1 + 1)});
    }
    sort(a.begin(), a.end());
    //for(auto c: a) cout << "vl: " << c.first << ", time: " << c.second << '\n';
    ll dp[10001];
    for(int i = 0; i <= 10000; ++i)
        dp[i] = LLONG_MAX;
    int n = a.size();
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = a[i].first; j <= 10000; ++j)
            if(j >= a[i].first && dp[j - a[i].first] != LLONG_MAX)
                dp[j] = min(dp[j - a[i].first] + a[i].second, dp[j]);
    }
    for(int i = 10000 - 1; i >= 0; --i)
        dp[i] = min(dp[i + 1], dp[i]);
    //cout << dp[h] << '\n';
    ll dp2[10001], cr = 0;
    priority_queue<pair<ll, pair<ll, bool>>> q;
    q.push({-t[0], {p[0] - s, 0}});
    q.push({-t[1], {p[1] - s, 1}});
    dp2[0] = 0;
    while(cr < h){
        auto th = q.top();
        q.pop();
        for(int i = cr + 1; i <= cr + th.second.first; ++i)
            dp2[i] = -th.first;
        cr = cr + th.second.first;
        th.first -= t[th.second.second];
        q.push(th);
    }
    ll rs = LLONG_MAX;
    for(int i = 0; i <= h; ++i)
        rs = min(rs, dp[i] + dp2[h - i]);
    //for(int i = 0; i <= h; ++i) cout << i << ") " << dp[i] + dp2[h - i] << '\n';
    cout << rs << '\n';
}

#include<bits/stdc++.h>
//#define DEBUG
#define FOR(i,n) for(int i=1;i<=n;i++)
#define FORZ(i,n) for(int i=0;i<n;i++)
#define ll long long
#define int64 long long
#define ull unsigned long long
#define pii pair<ll,ll>
#define pll pair<ll,ll>
#define piii pair<pair<int,int>,int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SIZE 10000002
#define MOD 998244353
#define LD long long double
#define bpc __builtin_popcount
#define gentum getnum
using namespace std;

inline ll getnum()
{
    char c = getchar();
    ll num,sign=1;
    for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;
    for(num=0;c>='0'&&c<='9';)
    {
        c-='0';
        num = num*10+c;
        c=getchar();
    }
    return num*sign;
}

vector<pii> V;
ll P[6],T[5];
ll DP[5004];

int main()
{
    for(int i=1;i<=2;i++)
    {
        P[i]=getnum();
        T[i]=getnum();
    }
    ll h=getnum(),s=getnum();

    P[1]-=s;
    P[2]-=s;
    P[3]=P[1]+P[2]+s;

    ll mx=max(T[1],T[2]);

    ll ans=LLONG_MAX;

    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=2;j++)
        {
            ll t=T[j]*i;
            if(t>=mx)
            {
                ll u1=t/T[1]-1;
                ll u2=t/T[2]-1;

                ll d=u1*P[1]+u2*P[2]+P[3];
                d=min(d,h);

                V.pb({t,d});
            }

            ll u1=t/T[1];
            ll u2=t/T[2];
            ll d=u1*P[1]+u2*P[2];

            if(d>=h)ans=min(ans,t);
        }
    }

    for(int i=1;i<=h;i++)
    {
        DP[i]=LLONG_MAX;
        for(pii p:V)
        {
            ll d=max(0LL,i-p.ss);
            DP[i]=min(DP[i],DP[d]+p.ff);
        }
    }

    ans=min(ans,DP[h]);

    cout<<ans;
}

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
using i64 = long long;
const int N = 2e5 + 10;
long long f[5010], dp[5010];

signed main() {
	long long p1, p2, t1, t2, h, s, p3;
	cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
	memset(f, 0x3f, sizeof f);
	f[0] = 0;
	for(int i = 1; i <= h ; i ++ ) {
	    f[i] = min(f[max(0ll, i - (p1 - s))] + t1, f[max(0ll, i - (p2 - s))] + t2);
		for(int j = 1 ; j <= i ; j ++ ) {
			if(t1 * j >= t2) { // p1自己操作j - 1次，然后12一起操作1次
			    long long dmg = (j - 1) * (p1 - s) + (t1 * j - t2) / t2 * (p2 - s) + p1 + p2 - s;
			    f[i] = min(f[i], f[max(0ll, i - dmg)] + t1 * j);
			}
			if(t2 * j >= t1) {
			    long long dmg = (j - 1) * (p2 - s) + (t2 * j - t1) / t1 * (p1 - s) + p1 + p2 - s;
			    f[i] = min(f[i], f[max(0ll, i - dmg)] + t2 * j);
			}
		}
	}
	cout << f[h] << endl;
}

//
//  Created by Henry Cafaro
//  Copyright © 2020 Henry Cafaro. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define ll long long

using namespace std;

int p1, p2, h,s;
ll t1,t2;

vector<ll> dp;

ll f(ll x){
    if(x >= h)
        return 0;
    if(dp[x] == -1){
        dp[x] = 100000000000000000;
        for(ll i = 1; i <= h; i++){
            ll dmg = (p1-s)*(i-1) + (p1-s);
            if((i*t1)/t2 - 1 >= 0){
                dmg += (p2-s)*((i*t1)/t2 - 1) + p2;
            }
            //cout << "1 " << i << " " << dmg << endl;
            dp[x] = min(dp[x], f(x+dmg) + i*t1);
        }
        for(ll i = 1; i <= h; i++){
            ll dmg = (p2-s)*(i);
            if((i*t2)/t1 - 1 >= 0){
                dmg += (p1-s)*((i*t2)/t1 - 1) + p1;
            }
            //cout << "2 " << i << " " << dmg << endl;

            dp[x] = min(dp[x], f(x+dmg) + i*t2);
        }

    }
    return dp[x];
}

void solve(){
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

    dp.assign(h+1, -1);

    cout << f(0) << endl;

//    for(int i = 0; i <= h; i++){
//        cout << i << " " << f(i) << endl;
//    }

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

}

#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <ranges>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

typedef long long LL;
// HMMMM
#define int LL

typedef pair<int, int> PII;
typedef pair<int, PII> PIII;

const int INF = 1e18 + 1;

int start_h;
int p1, t1;
int p2, t2;
int s;

vector<int> memo;

int f(int h) {
    int begin_h = h;
    // cout << "f(" << begin_h << ")" << endl;
    if (h <= 0) {
        //   cout << "f(" << begin_h << ") = " << 0 << endl;

        return 0;
    }
    int &res = memo[h];
    if (res != -1) return res;

    res = INF;
    int t = 0;
    int x = t1, y = t2;

    while (h > 0) {
        // cout << "h = " << h << ", t = " << t << endl;
        // cout << "x = " << x << ", y = " << y << endl;

        res = min(res, t + max(x, y) + f(h - (p1 + p2 - s)));
        // cout << "h = " << h << ", t = " << t << endl;
        // cout << "x = " << x << ", y = " << y << endl;
        if (x == y) {
            t = res;
            break;
        }
        if (x < y) {
            //   cout << "shooting for " << p1 << endl;
            t += x;
            y -= x;
            x -= x;
            h -= p1 - s;
            x = t1;
        } else if (y < x) {
            //   cout << "shooting for " << p2 << endl;

            t += y;
            x -= y;
            y -= y;
            h -= p2 - s;
            y = t2;
        } else {
            // assert(false);
        }
        // cout << "h = " << h << ", t = " << t << endl;
        // cout << "x = " << x << ", y = " << y << endl;
    }
    res = min(res, t);
    // cout << "f(" << begin_h << ") = " << res << endl;

    return res;
}

int solve() {
    cin >> p1 >> t1;
    cin >> p2 >> t2;
    cin >> start_h >> s;
    memo.resize(start_h + 1);
    for (auto &x : memo) x = -1;
    int res = f(start_h);
    return res;
}

#undef int
int main() {
    ios::sync_with_stdio(false);
    cin.exceptions(cin.failbit);

    cin.tie(0);
    int t = 1;
#ifdef DUPA
    cin >> t;
#endif
    for (int i = 0; i < t; i++) cout << solve() << endl;
}

#include <bits/stdc++.h>
#define ll long long
#define int __int128
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define vpii vector<pi>
#define il inline
#define ri register
#define all(a) a.begin(), a.end()
#define fr(a) freopen(a, "r", stdin)
#define fo(a) freopen(a, "w", stdout);
#define mod 998244353
#define debug puts("------------------------")
#define lowbit(x) (x&-x)
#define ls(x) x << 1
#define rs(x) x << 1 | 1
template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll ksm(ll a, ll b) {if (b == 0) return 1; ll ns = ksm(a, b >> 1); ns = ns * ns % mod; if (b & 1) ns = ns * a % mod; return ns;}
void Read(int &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
int  read() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
#define LOCAL
using namespace std;
const int maxn = 200005;
/**/
int p1, p2, t1, t2, h, s, dmg, qwq, f[10005];
/**/

bool check(int mid)
{
    int hp = h - dmg;
    int tot = (mid / t1) * (p1 - s);
    tot += (mid / t2) * (p2 - s);
    int win = mid / qwq;
    tot += win * s;
    if(tot >= hp) return 1;
    return 0;
}

int getgcd(int a, int b)
{
    return b ? getgcd(b, a % b) : a;
}

signed main()
{
    #if ONLINE_JUDGE
    #else
    fr("test.in");
    //fo("test.out");
    #endif
    p1 = read(); t1 = read();
    p2 = read(); t2 = read();
    if(t1 > t2) swap(p1, p2), swap(t1, t2);
    qwq = t1 * t2 / __gcd(t1, t2);
    // W(qwq); puts("");
    h = read(); s = read();
    int lim = 2500;
    vector<pi>g;
    for(int i = 1; i <= min(lim, qwq / t2); i++) // 2号打2500次后停下
    {
        int val = i * (p2 - s);
        val += ((t2 * i) / t1) * (p1 - s);
        if((t2 * i) / t1 != 0) val += s;
        g.pb({val, t2 * i});
    }
    for(int i = 1; i <= min(lim, qwq / t1); i++) // 2号打2500次后停下
    {
        int val = i * (p1 - s);
        val += ((t1 * i) / t2) * (p2 - s);
        if((t1 * i) / t2 != 0) val += s;
        g.pb({val, t1 * i});
    }
    memset(f, 0x3f, sizeof(f));
    f[0] = 0;
    int ans = 1e18;
    for(auto i : g)
    {
        int w = i.fi;
        int v = i.se;
        for(int j = w; j <= 10000; j++)
        {
            f[j] = min(f[j - w] + v, f[j]);
        }
    }
    for(int i = 0; i <= 10000; i++)
    {
        if(i >= h) ans = min(ans, f[i]);
        else
        {
            // int tmp = f[i];
            int rec = 1e18;
            int l = 1, r = 1e18;
            while(l <= r)
            {
                int mid = (l + r) >> 1;
                dmg = i;
                if(check(mid))
                {
                    rec = mid;
                    r = mid - 1;
                }
                else l = mid + 1;
            }
            ans = min(ans, rec + f[i]);
        }
    }
    W(ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e3+3;
const ll INF=1e18;
ll dp[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll p1,p2,h,s,t1,t2;
    cin>>p1>>t1>>p2>>t2>>h>>s;
    for(int i=1;i<=h;++i)
        dp[i]=INF;
    for(ll i=0;i<h;++i)
    {
        dp[min(i+p1-s,h)]=min(dp[min(i+p1-s,h)],dp[i]+t1);
        dp[min(i+p2-s,h)]=min(dp[min(i+p2-s,h)],dp[i]+t2);
        for(ll j=(t1+t2-1)/t1;j<=h;++j)
        {
            ll sum=(p1-s)*(j-1)+p1+p2-s+(p2-s)*((j*t1-t2)/t2);
            dp[min(i+sum,h)]=min(dp[min(i+sum,h)],dp[i]+t1*j);
        }
        for(ll j=(t1+t2-1)/t2;j<=h;++j)
        {
            ll sum=(p2-s)*(j-1)+p1+p2-s+(p1-s)*((j*t2-t1)/t1);
            dp[min(i+sum,h)]=min(dp[min(i+sum,h)],dp[i]+t2*j);
        }
    }
    cout<<dp[h];
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX 9223372036854775807
int a[200000],b[200000];
signed main()
{
    int p1,t1,p2,t2,h,s;
    scanf("%lld%lld%lld%lld%lld%lld",&p1,&t1,&p2,&t2,&h,&s);
    a[p1-s]=t1;
    a[p2-s]=t2;
    for(int i=1;i<=h;i++)
    {
        if(a[i]!=0)
        {
            if(a[i+p1-s]==0)
            {
                a[i+p1-s]=a[i]+t1;
            }
            a[i+p1-s]=min(a[i+p1-s],a[i]+t1);
            if(a[i+p2-s]==0)
            {
                a[i+p2-s]=a[i]+t2;
            }
            a[i+p2-s]=min(a[i+p2-s],a[i]+t2);
        }
    }
    int cd1,cd2;
    cd1=cd2=0;
    int now_sumpower=0;
    int nowtime=0;
    while(now_sumpower<=h*3+p1+p2)
    {
        if(t1-cd1==t2-cd2)
        {
            nowtime=nowtime+(t1-cd1);
            now_sumpower=now_sumpower+p1+p2-s;
            cd1=cd2=0;
        }
        else if(t1-cd1>t2-cd2)
        {
            nowtime=nowtime+(t2-cd2);
            cd1=cd1+(t2-cd2);
            cd2=0;
            now_sumpower=now_sumpower+(p2-s);
        }
        else
        {
            nowtime=nowtime+(t1-cd1);
            cd2=cd2+(t1-cd1);
            cd1=0;
            now_sumpower=now_sumpower+(p1-s);
        }
        int wait,wait_power;
        wait=0;
        wait_power=0;
        if((cd1+cd2)!=0)
        {
            wait_power=(cd1==0)?(p2):(p1);
            wait=(cd1==0)?(t2-cd2):(t1-cd1);
        }
        if(a[now_sumpower+wait_power]==0)
        {
            a[now_sumpower+wait_power]=nowtime+wait;
        }
        a[now_sumpower+wait_power]=min(a[now_sumpower+wait_power],nowtime+wait);
        if(b[now_sumpower]==0)
        {
            b[now_sumpower]=nowtime;
        }
        b[now_sumpower]=min(b[now_sumpower],nowtime);
        for(int i=1;i<=h;i++)
        {
            if(a[i]!=0)
            {
                if(b[i+now_sumpower]==0)
                {
                    b[i+now_sumpower]=a[i]+nowtime;
                }
                b[i+now_sumpower]=min(b[i+now_sumpower],a[i]+nowtime);
                if(a[i+now_sumpower+wait_power]==0)
                {
                    a[i+now_sumpower+wait_power]=a[i]+nowtime+wait;
                }
                a[i+now_sumpower+wait_power]=min(a[i+now_sumpower+wait_power],a[i]+nowtime+wait);
            }

        }
    }
    int ans=MAX;
    for(int i=h;i<=h+p1+p2+100;i++)
    {
        if(ans>a[i]&&a[i])
        {
            ans=a[i];
        }
        if(ans>b[i]&&b[i])
        {
            ans=b[i];
        }
    }
    printf("%lld\n",ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define se second
#define fi first
#define mpr make_pair
#define ull unsigned long long
//const int mod=1e9+7;
const int mod=998244353;
int add(int x,int y){
	x+=y;return x>=mod?x-mod:x;
}
void adto(int&x,int y){
	x+=y;
	x>=mod?x-=mod:x;
}
int mul(int x,int y){
	return 1ll*x*y%mod;
}
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=mul(ans,a);
		a=mul(a,a);
		b>>=1;
	}
	return ans;
}

const int maxn=5e3+10;
ll p1,t1,p2,t2,s,h;
ll dp[maxn<<2];
void solve(){
	cin>>p1>>t1>>p2>>t2>>h>>s;
	memset(dp,0x3f,sizeof dp);
	dp[0]=0;
	ll ans=dp[1];
	for(int i=0;i<h;i++){
		ll make;
		for(int j=1;;j++){
			if(j*t1<t2){
				make=i+j*(p1-s);
				if(make<h)dp[make]=min(dp[make],dp[i]+j*t1);
				else ans=min(ans,dp[i]+j*t1);
				if(make>=h)break;
				continue;
			}
			ll make=i+(j-1)*(p1-s)+(j*t1/t2-1)*(p2-s)+(p1+p2-s);
			if(make<h)dp[make]=min(dp[make],dp[i]+j*t1);
			else ans=min(ans,dp[i]+j*t1);
			if(make>=h)break;
		}
		for(int j=1;;j++){
			if(j*t2<t1){
				make=i+j*(p2-s);
				if(make<h)dp[make]=min(dp[make],dp[i]+j*t2);
				else ans=min(ans,dp[i]+j*t2);
				if(make>=h)break;
				continue;
			}
			ll make=i+(j-1)*(p2-s)+(j*t2/t1-1)*(p1-s)+(p1+p2-s);
			if(make<h)dp[make]=min(dp[make],dp[i]+j*t2);
			else ans=min(ans,dp[i]+j*t2);
			if(make>=h)break;
		}
	}
	cout<<ans<<"\n";
}

signed main(){

	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

// LUOGU_RID: 94210704
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 5010;
ll h, s, t1, p1, t2, p2, ans, tot;
ll weight[maxn], val[maxn];
ll dp[10010];
int main() {
	scanf("%lld%lld%lld%lld%lld%lld", &p1, &t1, &p2, &t2, &h, &s);
	p1 = p1 - s; p2 = p2 - s;
//	cout << p1 << " " << p2 << " " << t1 << " " << t2 << " attact" << endl;
	ans = 1e18;
	for (int i = 1; i <= h; i++) {
		ll tim = (ll)i * t1, value = p1 * (ll)i + (ll)(((ll)i * t1) / t2) * p2;
		if (value >= h) {
			ans = min(ans, tim); break;
		}
	}
	for (int i = 1; i <= h; i++) {
		ll tim = (ll)i * t2, value = (ll)i * p2 + (((ll)i * t2) / t1) * p1;
		if (value >= h) {
			ans = min(ans, tim); break;
		}
	}
	for (int i = 1; i <= h; i++) {
		if (!(((ll)i * t1) / t2)) continue;
		ll tim = (ll)i * t1, value = p1 * (ll)i + (ll)(((ll)i * t1) / t2) * p2 + s;
		if (value >= h) {ans = min(ans, tim); break;}
		else {
			weight[++tot] = value, val[tot] = tim;
		}
	}
	for (int i = 1; i <= h; i++) {
		if (!(((ll)i * t2) / t1)) continue;
 		ll tim = (ll)i * t2, value = s + (ll)i * p2 + (((ll)i * t2) / t1) * p1;
 		if (value >= h) {ans = min(ans, tim); break;}
		else {
			weight[++tot] = value, val[tot] = tim;
		}
	}
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
/*	for (int i = 1; i <= tot; i++) {
		cout << weight[i] << " " << val[i] << " object" << endl;
	}*/
	for (int i = 1; i <= tot; i++) {
		for (int j = 0; j <= h; j++) {
			dp[j+weight[i]] = min(dp[j+weight[i]], dp[j] + val[i]);
			//if (dp[j] == 0) cout << j << endl;
		}
	}
	for (int i = h; i <= 2 * h; i++) {
		ans = min(ans, dp[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <memory>
#include <deque>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <chrono>
#include <random>
#include <cassert>

using namespace std;

typedef long long ll;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

void solve() {
    ll p1, t1;
    ll p2, t2;
    ll h, s;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

    vector<vector<pair<ll, ll>>> tm(h + 1);

    const ll INF = 1000'000'000'000'000'000LL;
    vector<ll> dp(h + 1, INF);
    dp[0] = 0;

    ll res = INF;

    for (ll i = 0; i < h; ++i) {
        for (ll j = 0; j <= h; ++j) {
            ll tm = j * t1;
            ll k = (tm / t2);
            ll dmg = i + j * (p1 - s) + k * (p2 - s);
            if (dmg >= h) {
                res = min(res, dp[i] + tm);
                break;
            }

            dmg += (p1 + p2 - s);
            ll lastT2 = k * t2;
            tm += t1;

            if (tm - lastT2 < t2) tm += (t2 - (tm - lastT2));

            if (dmg >= h) {
                res = min(res, dp[i] + tm);
            } else {
                dp[dmg] = min(dp[dmg], dp[i] + tm);
            }
        }

        for (ll j = 0; j <= h; ++j) {
            ll tm = j * t2;
            ll k = (tm / t1);
            ll dmg = i + j * (p2 - s) + k * (p1 - s);
            if (dmg >= h) {
                res = min(res, dp[i] + tm);
                break;
            }

            dmg += (p1 + p2 - s);
            ll lastT1 = k * t1;
            tm += t2;
            if (tm - lastT1 < t1) tm += (t1 - (tm - lastT1));

            if (dmg >= h) {
                res = min(res, dp[i] + tm);
            } else {
                dp[dmg] = min(dp[dmg], dp[i] + tm);
            }
        }
    }

    cout << res << "\n";
}

int main() {
    startTime = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int tests = 1;
    // cin >> tests;

    for (int t = 0; t < tests; ++t) {
        solve();
    }

    return 0;
}

#include<bits/stdc++.h>
#define f first
#define s second
#define int long long
#define pii pair<int,int>
using namespace std;
const int N = 5e3 + 5, mod = 1e9 + 7; // !
int t, dp[N];
main(){
    int p1, t1;
    cin >> p1 >> t1;
    int p2, t2;
    cin >> p2 >> t2;
    int H, S; cin >> H >> S;

    for(int i = 1; i <= H; i++) {
        dp[i] = 1e17;

        for(int c1 = 1; c1 <= i; c1++) {
            int c2 = c1 * t1 / t2;
            int hn = i - c1 * (p1 - S) - c2 * (p2 - S) - (c2 > 0) * S; hn = max(hn, 0ll);
            dp[i] = min(dp[i], dp[hn] + t1 * c1);
        }
        for(int c2 = 1; c2 <= i; c2++) {
            int c1 = c2 * t2 / t1;
            int hn = i - c1 * (p1 - S) - c2 * (p2 - S) - (c1 > 0) * S; hn = max(hn, 0ll);
            dp[i] = min(dp[i], dp[hn] + t2 * c2);
        }
    }
    cout << dp[H];
 }

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <memory>
#include <deque>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <chrono>
#include <random>
#include <cassert>

using namespace std;

typedef long long ll;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

void solve() {
    ll p1, t1;
    ll p2, t2;
    ll h, s;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

    ll res = (h + p1 + p2 - s - 1) / (p1 + p2 - s) * max(t1, t2);

    vector<set<pair<ll, ll>>> tm(h + 1);
    tm[h].insert({0, 0});

    auto add = [&](ll newH, ll newX1, ll newX2) {
        if (max(newX1, newX2) > res) {
            return;
        }

        if (newH <= 0) {
            res = min(res, max(newX1, newX2));
            return;
        }

        if (tm[newH].empty()) {
            tm[newH].insert({newX1, newX2});
            return;
        }

        auto it = tm[newH].lower_bound({newX1, newX2});
        while (true) {
            if (it == tm[newH].end())
                break;
            if (it->second >= newX2) {
                it = tm[newH].erase(it);
            } else {
                break;
            }
        }

        // auto it = tm[newH].lower_bound({newX1, newX2});
        if (it != tm[newH].begin()) {
            it--;
            if (it->second <= newX2) {
                return;
            }
        }
        tm[newH].insert({newX1, newX2});
    };

    for (ll curH = h; curH >= 1; --curH) {
        for (auto [x1, x2] : tm[curH]) {
            if (x1 + t1 <= x2)
                add(curH - (p1 - s), x1 + t1, x2);
            else if (x2 + t2 <= x1)
                add(curH - (p2 - s), x1, x2 + t2);
            else {
                add(curH - (p1 - s), x1 + t1, x2);
                add(curH - (p2 - s), x1, x2 + t2);
                add(curH - (p1 + p2 - s), max(x1 + t1, x2 + t2), max(x1 + t1, x2 + t2));
            }

        }
    }

    cout << res << "\n";
}

int main() {
    startTime = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int tests = 1;
    // cin >> tests;

    for (int t = 0; t < tests; ++t) {
        solve();
    }

    return 0;
}

// LUOGU_RID: 90673472
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=15010;
int p1,t1,p2,t2,h,s,f[maxn],ans,cost[maxn];
int Find(int ted1,int ted2,int n)
{
	int lo=max(ted1,ted2),hi=1e16;
	while(lo<=hi)
	{
		int mid=lo+hi>>1;
		int c1=(mid-ted1)/t1,c2=(mid-ted2)/t2;
		if(c1*(p1-s)+c2*(p2-s)>=n) hi=mid-1;
		else lo=mid+1;
	}
	return lo;
}
signed main()
{
	scanf("%lld%lld%lld%lld%lld%lld",&p1,&t1,&p2,&t2,&h,&s);
	f[0]=0;
	for(int i=p1+p2-s;i<=h+p1+p2-s;i++)
	{
		cost[i]=Find(t1,t2,i-p1-p2+s);
	}
	for(int i=1;i<=h+p1+p2-s;i++)
	{
		f[i]=0x3f3f3f3f3f3f3f3f;
		for(int j=0;i-j>=p1+p2-s;j++)
		{
			int tmp=i-j;
			if(tmp<p1+p2-s) continue;
			f[i]=min(f[i],f[j]+cost[tmp]);
		}
	}
	ans=f[h];
	for(int i=h+1;i<=h+p1+p2-s;i++) ans=min(ans,f[i]);
	for(int i=0;i<h;i++)
	{
		ans=min(ans,f[i]+Find(0,0,h-i));
	}
	printf("%lld",ans);
	return 0;
}

// LUOGU_RID: 93988282
// QwQ
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
#define fi first
#define se second
typedef pair<int,int> PII;
typedef long long LL;
template <typename T> void inline read(T& x)
{
	x=0; int f=1; char ch;
	while((ch=getchar())>'9' || ch<'0') if(ch=='-') f=-1;
	while(ch>='0' && ch<='9') x=x*10+(ch^'0'),ch=getchar();
	x*=f;
};
const int N=5e3+5;
int h,s,p1,p2; LL t1,t2,dp[N];
int main()
{
	read(p1); read(t1); read(p2); read(t2); read(h); read(s);
	memset(dp,0x3f,sizeof(dp)); dp[0]=0;
	for(int i=1;i<=h;i++)
	{
		dp[i]=min(dp[max(0,i-(p1-s))]+t1,dp[max(0,i-(p2-s))]+t2);
		for(int j=1;j<=i;j++)
		{
			if(j*t1>=t2)
			{
				LL now=(j-1)*(p1-s)+(j*t1-t2)/t2*(p2-s)+(p1+p2-s);
				dp[i]=min(dp[i],dp[max(0LL,i-now)]+j*t1);
			}
			if(j*t2>=t1)
			{
				LL now=(j-1)*(p2-s)+(j*t2-t1)/t1*(p1-s)+(p1+p2-s);
				dp[i]=min(dp[i],dp[max(0LL,i-now)]+j*t2);
			}
		}
	}
	printf("%lld\n",dp[h]);
	return (0-0); // QwQ
}

// QwQ
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
#define fi first
#define se second
typedef pair<int,int> PII;
typedef long long LL;
template <typename T> void inline read(T& x)
{
	x=0; int f=1; char ch;
	while((ch=getchar())>'9' || ch<'0') if(ch=='-') f=-1;
	while(ch>='0' && ch<='9') x=x*10+(ch^'0'),ch=getchar();
	x*=f;
};
const int N=5e3+5;
int h,s,p1,p2; LL t1,t2,dp[N];
int main()
{
	read(p1); read(t1); read(p2); read(t2); read(h); read(s);
	memset(dp,0x3f,sizeof(dp)); dp[0]=0;
	for(int i=1;i<=h;i++)
	{
		dp[i]=min(dp[max(0,i-(p1-s))]+t1,dp[max(0,i-(p2-s))]+t2);
		for(int j=1;j<=i;j++)
		{
			if(j*t1>=t2)
			{
				LL now=(j-1)*(p1-s)+(j*t1-t2)/t2*(p2-s)+(p1+p2-s);
				dp[i]=min(dp[i],dp[max(0LL,i-now)]+j*t1);
			}
			if(j*t2>=t1)
			{
				LL now=(j-1)*(p2-s)+(j*t2-t1)/t1*(p1-s)+(p1+p2-s);
				dp[i]=min(dp[i],dp[max(0LL,i-now)]+j*t2);
			}
		}
	}
	printf("%lld\n",dp[h]);
	return (0-0); // QwQ
}

// Come on, God dammit!
#include "bits/stdc++.h"
using namespace std;

#ifdef debug
#include "debug.h"
#else
#define dbg(...)
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse4.2,bmi,bmi2,popcnt,lzcnt")
#endif

template <class Fun> struct yc_result {
    Fun fun_;
    template <class T> explicit yc_result(T&& fun) : fun_(std::forward<T>(fun)) {}
    template <class... Args> decltype(auto) operator()(Args&&... args) {
        return fun_(std::ref(*this), std::forward<Args>(args)...);
    }
};
template <class Fun> decltype(auto) yc(Fun&& fun) {
    return yc_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

void yes(bool caps = true) { cout << (caps ? "YES" : "Yes") << '\n'; }
void no(bool caps = true) { cout << (caps ? "NO" : "No") << '\n'; }

template <typename T> bool ckmin(T& a, T b) { return b < a && (a = b, true); }
template <typename T> bool ckmax(T& a, T b) { return b > a && (a = b, true); }
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;

#define int int64_t
#define pb push_back
#define all(v) begin(v), end(v)
#define ss(v) (int)v.size()
using ld = long double;

// VERIFY BEFORE USING
const int inf = 4e18;
const int maxn = 2e5 + 10;

void testCase() {
    array<int, 2> power, timeout;
    for (int i = 0; i < 2; i++) {
        cin >> power[i] >> timeout[i];
    }
    int p, s;
    cin >> p >> s;
    vector<int> dp(p + 1, inf);
    dp[0] = 0;

    for (int i = 1; i <= p; i++) {
        for (int k = 0; k < 2; k++) {
            for (int j = 1; j <= i; j++) {
                int t = j * timeout[k];
                int damage =
                    j * (power[k] - s) + (t / timeout[k ^ 1]) * (power[k ^ 1] - s) + ((t >= timeout[k ^ 1]) * s);
                ckmin(dp[i], dp[max(int(0), i - damage)] + t);
            }
        }
    }

    cout << dp[p];
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    int tc = 1;
    // cin >> tc;
    for (int testNo = 1; testNo <= tc; testNo++) {
        // cout << "Case #" << testNo << ": ";
        testCase();
    }
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int N=5100;
ll p1,t1,p2,t2,h,s;
ll con[N];
int main(){
	scanf("%lld%lld%lld%lld%lld%lld",&p1,&t1,&p2,&t2,&h,&s);
	for(int i=0;i<N;i++){
		con[i]=inf;
	}
	con[0]=0;
	for(int i=1;i<=h;i++){
		ll t=i*t1;
		ll a=t/t1*(p1-s),b=t/t2*(p2-s);
		ll hh=a+b;
		if(t>=t2){
			hh+=s;
		}//特判一下
		if(hh<=h){
			con[hh]=min(con[hh],t);
		}else {
			con[h]=min(con[h],t);
		}

		t=i*t2;
		a=t/t1*(p1-s),b=t/t2*(p2-s);
		hh=a+b;
		if(t>=t1){
			hh+=s;
		}//特判一下
		if(hh<=h){
			con[hh]=min(con[hh],t);
		}else {
			con[h]=min(con[h],t);
		}
	}//表示的是次数
	for(int i=0;i<=h;i++){
		for(int j=0;j<=i;j++){
			int k=min(i+j,(int)h);
			con[k]=min(con[k],con[i]+con[j]);
		}
	}
	printf("%lld\n",con[h]);
	return 0;
}

// LUOGU_RID: 93520668
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5005;
inline int read()
{
  int t=0,f=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
  while(c>='0'&&c<='9')t=t*10+c-48,c=getchar();
  return t*f;
}
int p1,t1,p2,t2,h,s;
int a[N];
int dp[N];
signed main() {
    memset(a,-1,sizeof(a));
   p1=read();t1=read();p2=read();t2=read();h=read();s=read();
    for(int i1=1;i1<=h;i1++)
    {
        int time=t1*i1;
        int i2=time/t2;
        int ht=(p1-s)*i1+(p2-s)*i2;
        if(i2>0)
        {
            ht+=s;
        }
        ht=min(ht,h);
        if(a[ht]==-1||a[ht]>time)
        {
            a[ht]=time;
        }
    }
    for(int i2=1;i2<=h;i2++)
    {
        int time=t2*i2;
        int i1=time/t1;
        int ht=(p1-s)*i1+(p2-s)*i2;
        if(i1>0)
        {
            ht+=s;
        }
        ht=min(ht,h);
        if(a[ht]==-1||a[ht]>time)
        {
            a[ht]=time;
        }
    }
    for(int i=h-1;i>0;i--)
    {
        if(a[i]==-1)
        {
            a[i]=a[i+1];
        }else{
            a[i]=min(a[i],a[i+1]);
        }
    }
    for(int i=1;i<=h;i++)
    {
        dp[i]=a[i];
        for(int j=1;j<i;j++)
        {
            dp[i]=min(dp[i],dp[j]+a[i - j]);
        }
    }
    cout<<dp[h]<<endl;
    return 0;
}

// LUOGU_RID: 93518196
#include<bits/stdc++.h>
using namespace std;
long long read()
{
	long long sum=0,fh=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')fh=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=(sum<<3)+(sum<<1)+(ch^48);ch=getchar();}
	return sum*fh;
}
#define Maxn 5010
long long f[Maxn];
int p[2];
long long t[2];
long long Mn[Maxn<<1];
int Atk[Maxn];
long long ttm[Maxn];
int main()
{
	memset(Mn,0x3f,sizeof(Mn));
	memset(f,0x3f,sizeof(f));
	long long INF=Mn[0];
	p[0]=read();
	t[0]=read();
	p[1]=read();
	t[1]=read();
	int hp=read();
	int def=read();
	long long ta=0;
	long long tb=0;
	int atka=0;
	int atkb=0;
	int tot=0;
	while(1)
	{
		++tot;
		if(ta+t[0]<tb+t[1])
		{
			atka+=p[0]-def;
			Atk[tot]=atka+atkb;
			ta+=t[0];
			ttm[tot]=ta;
			// if(atkb==0)Mn[]=min(Mn[],)
			if(atkb) Mn[atka+atkb+def]=min(Mn[atka+atkb+def],ta);
			if(Atk[tot]>hp)break;
		}
		else if(ta+t[0]>tb+t[1])
		{
			atkb+=p[1]-def;
			Atk[tot]=atka+atkb;
			tb+=t[1];
			ttm[tot]=tb;
			if(atka)Mn[atka+atkb+def]=min(Mn[atka+atkb+def],tb);
			if(Atk[tot]>hp)break;
		}
		else
		{
			Atk[tot]=atka+atkb+p[0]+p[1]-def;
			ttm[tot]=Mn[atka+atkb+p[0]+p[1]-def]=ta+t[0];
			break;
		}
	}
	for(int i=10000;i>=1;--i)
	{
		Mn[i]=min(Mn[i+1],Mn[i]);
	}
	f[hp]=0;
	for(int i=hp;i>=1;--i)
	{
		if(f[i]==INF)continue;
		for(int j=1;j<=i;++j)
		{
			if(Mn[j]!=INF)
			{
				f[i-j]=min(f[i-j],f[i]+Mn[j]);
			}
		}
	}
	long long ans=f[0];
	for(int i=1;i<=hp;++i)
	{
		for(int j=1;j<=tot;++j)
		{
			if(Atk[j]>=i)
			{
				ans=min(ans,f[i]+ttm[j]);
			}
		}
	}
	printf("%lld\n",ans);
}

// Come on, God dammit!
#include "bits/stdc++.h"
using namespace std;

#ifdef debug
#include "debug.h"
#else
#define dbg(...)
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse4.2,bmi,bmi2,popcnt,lzcnt")
#endif

template <class Fun> struct yc_result {
    Fun fun_;
    template <class T> explicit yc_result(T&& fun) : fun_(std::forward<T>(fun)) {}
    template <class... Args> decltype(auto) operator()(Args&&... args) {
        return fun_(std::ref(*this), std::forward<Args>(args)...);
    }
};
template <class Fun> decltype(auto) yc(Fun&& fun) {
    return yc_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

void yes(bool caps = true) { cout << (caps ? "YES" : "Yes") << '\n'; }
void no(bool caps = true) { cout << (caps ? "NO" : "No") << '\n'; }

template <typename T> bool ckmin(T& a, T b) { return b < a && (a = b, true); }
template <typename T> bool ckmax(T& a, T b) { return b > a && (a = b, true); }
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;

#define int int64_t
#define pb push_back
#define all(v) begin(v), end(v)
#define ss(v) (int)v.size()
using ld = long double;

// VERIFY BEFORE USING
const int inf = 4e18;
const int maxn = 2e5 + 10;

void testCase() {
    array<int, 2> power, timeout;
    for (int i = 0; i < 2; i++) {
        cin >> power[i] >> timeout[i];
    }
    int p, s;
    cin >> p >> s;
    vector<int> dp(p + 1, inf);
    dp[0] = 0;
    for (int i = 1; i <= p; i++) {
        for (int k = 0; k < 2; k++) {
            for (int j = 1; j <= i; j++) {
                int t = j * timeout[k];
                int d1 = min(i, min(j, t / timeout[k ^ 1]) * (power[k] + power[k ^ 1] - s));
                int d2 = min(i, j * (power[k] - s) + (t / timeout[k ^ 1]) * (power[k ^ 1] - s) +
                                    (t >= timeout[k ^ 1] ? s : 0));
                ckmin(dp[i], dp[i - d1] + t);
                ckmin(dp[i], dp[i - d2] + t);
            }
        }
    }

    // dbg(dp);
    cout << dp[p];
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    int tc = 1;
    // cin >> tc;
    for (int testNo = 1; testNo <= tc; testNo++) {
        // cout << "Case #" << testNo << ": ";
        testCase();
    }
}

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using uint = unsigned int; using ull = unsigned long long; using ld = long double; using i128 = __int128_t;
using P = pair<int, int>; using LP = pair<ll, ll>; using LT = tuple<ll, ll, ll>; using LT4 =  tuple<ll, ll, ll, ll>;
typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> v3l; typedef vector<v3l> v4l; typedef vector<v4l> v5l;
typedef vector<LP> vlp; typedef vector<vlp> vvlp; typedef vector<LT> vlt; typedef vector<vlt> vvlt; typedef vector<LT4> vlt4; typedef vector<string> vs; typedef vector<vs> vvs;
typedef vector<ld> vd; typedef vector<vd> vvd; typedef vector<bool> vb; typedef vector<vb> vvb;
template<typename T> using pq = priority_queue<T>; template<typename T> using mpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T> class infinity{ public: static constexpr T MAX=numeric_limits<T>::max(); static constexpr T MIN=numeric_limits<T>::min(); static constexpr T val=numeric_limits<T>::max()/2-1e6; static constexpr T mval=numeric_limits<T>::min()/2+1e6; };
const int INF = infinity<int>::val; const ll LINF = infinity<ll>::val; const ld DINF = infinity<ld>::val;
#define _overload5(a, b, c, d, e, name, ...) name
#define _overload4(a, b, c, d, name, ...) name
#define _overload3(a, b, c, name, ...) name
#define _rep0(n) for(ll i = 0; (ll)(i) < n; ++i)
#define _rep1(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define _rep2(i, a, b) for(ll i = (ll)(a); i < (ll)(b); ++i)
#define _rep3(i, a, b, c) for(ll i = (ll)(a); i < (ll)(b); i += (ll)(c))
#define rep(...) _overload4(__VA_ARGS__, _rep3, _rep2, _rep1, _rep0)(__VA_ARGS__)
#define _per0(n) for(ll i = 0; i < (ll)(n); ++i)
#define _per1(i, n) for(ll i = (ll)(n)-1; i >= 0; --i)
#define _per2(i, a, b) for(ll i = (ll)(b)-1; i >= (ll)(a); --i)
#define _per3(i, a, b, c) for(ll i = (ll)(b)-1; i >= (ll)(a); i -= (ll)(c))
#define rep_r(...) _overload4(__VA_ARGS__, _per3, _per2, _per1, _per0)(__VA_ARGS__)
#define _fore0(a) rep(a.size())
#define _fore1(i, a) for(auto &&i : a)
#define _fore2(a, b, v) for(auto &&[a, b] : v)
#define _fore3(a, b, c, v) for(auto &&[a, b, c] : v)
#define _fore4(a, b, c, d, v) for(auto &&[a, b, c, d] : v)
#define fore(...) _overload5(__VA_ARGS__, _fore4, _fore3, _fore2, _fore1, _fore0)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define rng_of(v, l, r) (v).begin() + l, (v).begin() + r
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define v3(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define v4(type, name, a, b, c, ...) vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

struct RandGen {
  using ud = uniform_int_distribution<ll>; mt19937 mt; RandGen() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}
  ll l(ll a, ll b) { ud d(a, b - 1); return d(mt); }
  LP lp(ll a, ll b, bool rng = true) { ll x = l(a, b - 1), y = l(rng ? x + 1 : a, b - 1); return {x, y}; }
  vl vecl(ll n, ll a, ll b) { ud d(a, b - 1); vl ret(n); rep(i, n) ret[i] = d(mt); return ret; }
  vl vecperm(ll n, ll from = 0) { vl perm(n); iota(all(perm), from); shuffle(perm); return perm; }
  string str(ll n, string op) { vl fig = vecl(n, 0, op.size()); string s; rep(i, n) s.pb(op[fig[i]]); return s; }
  string straz(ll n, ll a = 0, ll z = 26) { vl az = vecl(n, a, z); string s; rep(i, n) s.pb('a' + az[i]); return s; }
  string strnum(ll n, ll zero = 0, ll ten = 10) { vl zt = vecl(n, zero, ten); string s; rep(i, n) s.pb('0' + zt[i]); return s; }
  template<typename T> void shuffle(vector<T> &a) { std::shuffle(all(a), mt); }
};
// デバッグ系
#define dout cout
template<typename T, typename=void> struct is_specialize:false_type{};
template<typename T> struct is_specialize<T, typename conditional<false,typename T::iterator, void>::type>:true_type{};
template<typename T> struct is_specialize<T, typename conditional<false,decltype(T::first), void>::type>:true_type{};
template<typename T> struct is_specialize<T, enable_if_t<is_integral<T>::value, void>>:true_type{};
void dump(const char &t) { dout<<t; } void dump(const string &t) { dout<<t; } void dump(const bool &t) { dout<<(t ? "true" : "false"); }
template<typename T, enable_if_t<!is_specialize<T>::value, nullptr_t> =nullptr> void dump(const T&t) { dout << t; }
template<typename T> void dump(const T&t, enable_if_t<is_integral<T>::value>* =nullptr) { string tmp;if(t==infinity<T>::val||t==infinity<T>::MAX)tmp="inf";if(is_signed<T>::value&&(t==infinity<T>::mval||t==infinity<T>::MIN))tmp="-inf";if(tmp.empty())tmp=to_string(t);dout<<tmp; }
template<typename T, typename U, typename V> void dump(const tuple<T, U, V>&t) { dout<<"("; dump(get<0>(t)); dout<<" "; dump(get<1>(t)); dout << " "; dump(get<2>(t)); dout << ")"; }
template<typename T, typename U, typename V, typename S> void dump(const tuple<T, U, V, S>&t) { dout<<"("; dump(get<0>(t)); dout<<" "; dump(get<1>(t)); dout << " "; dump(get<2>(t)); dout << " "; dump(get<3>(t)); dout << ")"; }
template<typename T,typename U> void dump(const pair<T,U>&);
template<typename T> void dump(const T&t, enable_if_t<!is_void<typename T::iterator>::value>* =nullptr) { dout << "{ "; for(auto it=t.begin();it!=t.end();){ dump(*it); dout << (++it==t.end() ? "" : " "); } dout<<" }"; }
template<typename T,typename U> void dump(const pair<T,U>&t) { dout<<"("; dump(t.first); dout<<" "; dump(t.second); dout << ")"; }
void trace() { dout << "\n"; } template<typename Head, typename... Tail> void trace(Head&&head, Tail&&... tail) { dump(head); if(sizeof...(tail)) dout<<", "; trace(forward<Tail>(tail)...); }
#ifdef ONLINE_JUDGE
#define debug(...) (void(0))
#else
#define debug(...) do {dout<<#__VA_ARGS__<<" = ";trace(__VA_ARGS__); } while(0)
#endif
// 入出力系
#define LL(...) ll __VA_ARGS__; IN(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__; IN(__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__; IN(__VA_ARGS__)
#define _vl(name, size) vl name(size); IN(name)
#define _vl2(name, size, off) vl name(size); IN(name); rep(i, size) name[i]-=off
#define VL(...) _overload3(__VA_ARGS__, _vl2, _vl)(__VA_ARGS__)
#define VEC(type, name, size) vector<type> name(size); IN(name)
#define VEC2(type, name1, name2, size) vector<type> name1(size), name2(size); for(int i = 0; i < size; i++) IN(name1[i], name2[i])
#define VEC3(type, name1, name2, name3, size) vector<type> name1(size), name2(size), name3(size); for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i])
#define VEC4(type, name1, name2, name3, name4, size) vector<type> name1(size), name2(size), name3(size), name4(size); for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i], name4[i]);
#define VV(type, name, h, w) vector<vector<type>> name(h, vector<type>(w)); IN(name)
void scan(int &a) { cin >> a; } void scan(long long &a) { cin >> a; } void scan(char &a) { cin >> a; } void scan(double &a) { cin >> a; } void scan(string &a) { cin >> a; }
template <class T> void scan(T &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
void IN() {} template <class Head, class... Tail> void IN(Head &head, Tail &...tail) { scan(head); IN(tail...); }
#define OUTRET(...) { { OUT(__VA_ARGS__); return; } }
template <class T, class S> ostream &operator<<(ostream &os, const pair<T, S> &p) { return os << p.first << " " << p.second; }
void OUT() { cout << '\n'; } template <typename Head, typename... Tail> void OUT(const Head &head, const Tail &...tail) { cout << head; if(sizeof...(tail)) cout << ' '; OUT(tail...); }
template<class T, class S = ll> void OUTARRAY(vector<T>& v, S offset = S(0), string sep = " ") { rep(i, v.size()) { if (i > 0) cout << sep; if (offset != T(0)) { T t; t = v[i] + offset; cout << t; } else cout << v[i]; } cout << "\n"; }
template<class T, class S = ll> void OUTMAT(vector<vector<T>>& v, S offset = S(0)) { rep(i, v.size()) { OUTARRAY(v[i], offset); } }
template<typename T> void OUTBIN(T &a, int d) { for (int i = d - 1; i >= 0; i--) cout << ((a >> i) & (T)1); cout << "\n"; }
template<typename Q, typename A> void IQUERY(initializer_list<Q> q, A &a, string str = "? ") { cout << str; vector<Q> v(q); OUTARRAY(v); cout.flush(); cin >> a; }
// template<typename Q, typename A> void IQUERY(initializer_list<Q> q, A &a, string str = "? ") { vector<Q> query(q); RandGen rg;
//   a = query[0] ? A() : A();
// }
template<typename A> void IANSWER(initializer_list<A> a, string str = "! ") { cout << str; vector<A> v(a); OUTARRAY(v); cout.flush(); }
// 数値系
int ceil_pow2(ll n) { int x = 0; while ((1ULL << x) < (ull)(n)) x++; return x; }
int floor_pow2(ll n) { int x = 0; while ((1ULL << (x + 1)) <= (ull)(n)) x++; return x; }
pair<ll, ll> sqrtll(ll n) { ll x = round(sqrt(n)); if (x * x > n) --x; return {x, x + (x * x != n)}; }
ll POW(__uint128_t x, int n) { assert(n >= 0); ll res = 1; for(; n; n >>= 1, x *= x) if(n & 1) res *= x; return res; }
vl primes(const ll n) { vb isp(n + 1, true); for(ll i = 2; i * i <= n; i++) { if ((i > 2 && i % 2 == 0) || !isp[i]) continue; for(ll j = i * i; j <= n; j += i) isp[j] = 0; } vl ret; for(ll i = 2; i <= n; i++) if (isp[i]) ret.emplace_back(i); return ret; }
vl divisor(ll n) { vl ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.pb(i); if (i * i != n) ret.pb(n / i); } } sort(all(ret)); return ret; }
template<typename T> vl digits(T n) { assert(n >= 0); vl ret; while(n > 0) { ret.pb(n % 10); n /= 10; } return ret; }
template<class T, enable_if_t<is_integral<T>::value, nullptr_t> = nullptr> int msb(T x){ if (sizeof(x) == 4) return 31 - __builtin_clz(x); else return 63 - __builtin_clzll(x); }
template<class T, enable_if_t<is_integral<T>::value, nullptr_t> = nullptr> int lsb(T x){ if (sizeof(x) == 4) return __builtin_ctz(x); else return __builtin_ctzll(x); }
template<typename T, typename S> T ceil(T x, S y) { assert(y); return (y < 0 ? ceil(-x, -y) : (x > 0 ? (x + y - 1) / y : x / y)); }
template<typename T, typename S> T floor(T x, S y) { assert(y); return (y < 0 ? floor(-x, -y) : (x > 0 ? x / y : (x - y + 1) / y)); }
template<typename T = ll> T sum_of(const vector<T> &v, int l = 0, int r = INF) { return accumulate(rng_of(v, l, min(r, (int)v.size())), T(0)); }
ll max(int x, ll y) { return max((ll)x, y); } ll max(ll x, int y) { return max(x, (ll)y); }
ll min(int x, ll y) { return min((ll)x, y); } ll min(ll x, int y) { return min(x, (ll)y); }
ll mex(vl& v) { ll n = v.size(); vb S(n + 1); for (auto a: v) if (a <= n) S[a] = 1; ll ret = 0; while (S[ret]) ret++; return ret; }
// 操作系
template<class T> void rotate(vector<vector<T>> &a) { ll n = a.size(), m = a[0].size(); vector<vector<T>> ret(m, vector<T>(n, 0)); rep(i, n) rep(j, m) ret[j][n - 1 - i] = a[i][j]; a = ret; }
template<typename T> void uniq(vector<T>&a) { sort(all(a)); a.erase(unique(all(a)), a.end()); }
template<typename T> void comp(vector<T>&a) { vector<T> b = a; uniq(b); rep(i, a.size()) a[i] = lower_bound(all(b), a[i]) - b.begin(); }
template<class T = ll> pair<unordered_map<ll, ll>, unordered_map<ll, ll>> compmap(vector<T> &a) { vector<T> ca = a; comp(ca); unordered_map<ll, ll> ret, rev; rep(i, ca.size()) { ret[a[i]] = ca[i]; rev[ca[i]] = a[i]; } return mp(ret, rev); }
template<class T, class U> bool chmin(T &a, const U &b) { if (b < a) { a = b; return 1;} return 0; }
template<class T, class U> bool chmax(T &a, const U &b) { if (b > a) { a = b; return 1;} return 0; }
template<class T> int lbs(vector<T> &a, const T &b) { return lower_bound(all(a), b) - a.begin(); };
template<class T> int ubs(vector<T> &a, const T &b) { return upper_bound(all(a), b) - a.begin(); };
ll binary_search(function<bool(ll)> check, ll ok, ll ng, bool safe=true) { if (safe) { assert(check(ok)); assert(!check(ng)); } while (abs(ok - ng) > 1) { auto x = (ng + ok) / 2; if (check(x)) ok = x; else ng = x; } return ok; }
template<class T> vector<T> csum(vector<T> &a) { vl ret(a.size() + 1, 0); rep(i, a.size()) ret[i + 1] = ret[i] + a[i]; return ret; }
template<class S> vector<pair<S, int>> RLE(const vector<S> &v) { vector<pair<S, int>> res; for(auto &e : v) if(res.empty() or res.back().first != e) res.emplace_back(e, 1); else res.back().second++; return res; }
vector<pair<char, int>> RLE(const string &v) { vector<pair<char, int>> res; for(auto &e : v) if(res.empty() or res.back().first != e) res.emplace_back(e, 1); else res.back().second++; return res; }
template <class T, class S, class U> bool incl(const T &x, const S &l, const U &r) { return l <= x and x < r; }
void change_bit(ll &x, int b, int i) { assert(b < 63); if (!!(x & 1ll << b) ^ i) x ^= 1ll << b;  }
bool is_palindrome(string s) { rep(i, (s.size() + 1) / 2) if (s[i] != s[s.size() - 1 - i]) { return false; } return true; }
const string drul = "DRUL"; vl dx = {1, 0, -1, 0}; vl dy = {0, 1, 0, -1};

ll solve(ll n, vl a) {
  ll ans = n - a[0]; return ans;
}

ll naive(ll n, vl a) {
  ll ans = n + a[0]; return ans;
}

void compare(bool check = true) { RandGen rg; ll c = 0, loop = 10;
  while (++c) { if (c % loop == 0) cout << "reached " << c / loop << "loop" <<  "\n", cout.flush();
    ll n = 10;
    vl a = rg.vecl(n, 1, 1e2);
    auto so = solve(n, a); auto na = naive(n, a);
    if (!check || na != so) { cout << c << "times tried" << "\n";
      debug(n, a); debug(so); debug(na);
    if (check || (!check && c > loop)) break; }
  }
}

void solve() {
  LL(p1, t1, p2, t2, h, s);

  // if (t1 == t2) OUTRET(ceil(h, p1 + p2 - s) * t1);
  if (t1 > t2) { swap(t1, t2); swap(p1, p2); }

  vv(ll, dp, h + 1, h + 5, LINF);
  dp[0][0] = 0;

  ll both = p1 + p2 - s;
  p1 -= s; p2 -= s;

  ll ans = LINF;
  rep(i, h + 1) rep(j, h + 1) {
    if (dp[i][j] == LINF) continue;

    // 1を打つ
    if (t1 * (j + 1) / t2 > t1 * j / t2) {
      if (i + p2 >= h) chmin(ans, dp[i][j] + (t1 * j / t2 + 1) * t2);
      chmin(dp[min(h, i + p1 + p2)][j + 1], dp[i][j] + t1);
      chmin(dp[min(h, i + both)][0], dp[i][j] + t1);
    } else {
      chmin(dp[min(h, i + p1)][j + 1], dp[i][j] + t1);
      chmin(dp[min(h, i + (t2 / t1 - 1) * p1 + both)][0], dp[i][j] + t2);
    }
  }

  // debug(dp[5]);
  // debug(dp[21]);

  rep(i, h + 1) chmin(ans, dp[h][i]);
  OUT(ans);
}

signed main() {
  cin.tie(0)->sync_with_stdio(0); cout.tie(0); cout << fixed << setprecision(20);
  int t = 1; //cin >> t;
  while (t--) solve();
  // while (t--) compare();
}

#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pb push_back
#define inf 4557430888798830399
using namespace std;
const ll N=15010;
ll p1,t1;
ll p2,t2;
ll h,s,n;
ll g[N];
ll f[N];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	memset(g,inf,sizeof g);
	memset(f,inf,sizeof f);
	cin>>p1>>t1;
	cin>>p2>>t2;
	cin>>h>>s;
	n=h;
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=i;j++){
			ll x=i-j*(p1-s)-(p1+p2-s);
			if(x<=0){
				g[i]=min(g[i],max(j*t1+t1,t2));
			}else{
				ll k=(x-1)/(p2-s)+1;
				g[i]=min(g[i],max(j*t1+t1,k*t2+t2));
			}
		}
	}
	f[0]=0;
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<i;j++){
			f[i]=min(f[i],f[j]+g[i-j]);
		}
	}
	cout<<min(f[h],min(t1*((h-1)/(p1-s)+1),t2*((h-1)/(p2-s)+1)));
	return 0;
}

#include <bits/stdc++.h>
#include <array>
#include <unordered_map>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
unsigned seed = chrono::system_clock::now().time_since_epoch().count();
using ll = long long;
using ull = unsigned long long;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll _p1, _t1, _p2, _t2, h, s;
    cin >> _p1 >> _t1 >> _p2 >> _t2 >> h >> s;
    vector<ll> dp(h + 1, -1);
    const ll inf = 1ll<<60;
    auto f = [&](auto self, int H){
        if(H <= 0 || H > h) return 0ll;
        if(dp[H] != -1) return dp[H];
        ll p1 = _p1, t1 = _t1, p2 = _p2, t2 = _t2;
        ll ans = inf;
        for(int r = 0; r < 2; r++){
            for(int i = 1; i <= H; i++){
                int shoots_1 = i;
                int shoots_2 = ((i * t1) / t2);
                int damage_1 = shoots_1 * (p1 - s);
                int damage_2 = shoots_2 * (p2 - s);
                int w = damage_1 + damage_2;
                if(w > H){
                    ans = min(ans, i * t1);
                    continue;
                }
                ans = min(ans, i * t1 + self(self, H - w));
                if (shoots_2 > 0) {
                    int nw = w + s;
                    if (nw > H) {
                        ans = min(ans, i * t1);
                    } else {
                        ans = min(ans, i * t1 + self(self, H - nw));
                    }
                }
            }
            swap(p1, p2);
            swap(t1, t2);
        }
        return dp[H] = ans;
    };
    cout << f(f, h) << endl;
    return 0;
}

#include <bits/stdc++.h>
#include <array>
#include <unordered_map>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
unsigned seed = chrono::system_clock::now().time_since_epoch().count();
using ll = long long;
using ull = unsigned long long;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll _p1, _t1, _p2, _t2, h, s;
    cin >> _p1 >> _t1 >> _p2 >> _t2 >> h >> s;
    const ll inf = 1ll<<60;
    vector<ll> dp(h + 1, inf);
    dp[0] = 0;
    for(int j = 1; j <= h; j++){
        ll p1 = _p1, t1 = _t1, p2 = _p2, t2 = _t2;
        ll ans = inf;
        for(int r = 0; r < 2; r++){
            for(int i = 1; i <= j; i++){
                ll shoots_1 = i;
                ll shoots_2 = ((i * t1) / t2);
                ll damage_1 = shoots_1 * (p1 - s);
                ll damage_2 = shoots_2 * (p2 - s);
                ll w = damage_1 + damage_2;
                if(w > j){
                    ans = min(ans, i * t1);
                    continue;
                }
                ans = min(ans, i * t1 + dp[j - w]);
                if (shoots_2 > 0) {
                    ll nw = w + s;
                    if (nw > j) {
                        ans = min(ans, i * t1);
                    } else {
                        ans = min(ans, i * t1 + dp[j - nw]);
                    }
                }
            }
            swap(p1, p2);
            swap(t1, t2);
        }
        dp[j] = ans;
    }
    cout << dp[h] << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
//f(i+(p-s))=f(i)+t;
//考虑第一个枪q次，且最后一次和二一起攻击
//f[i+p1+(q-1)*(p1-s)+(p2-s)*(q*t1)/t2]=f[i]+q*t1;
//f[i+p2+(q-1)*(p2-s)+(p1-s)*(q*t2)/t1]=f[i]+q*t2;
const int N=6000;
int f[N],p1,p2,t1,t2,h,s;
signed main(){
	cin>>p1>>t1>>p2>>t2>>h>>s;
	int d1=p1-s,d2=p2-s;//伤害1，伤害2
	memset(f,0x3f3f3f3f,sizeof(f));
	f[0]=0;
	for(int i=0;i<h;i++){
		f[min(h,i+d1)]=min(f[min(h,i+d1)],f[i]+t1);
		f[min(h,i+d2)]=min(f[min(h,i+d2)],f[i]+t2);
		for(int j=1;j<=((h-i)/min(d1,d2));j++){
			int x=i+d1*j+d2*floor(j*t1/t2)+s;
			int y=i+d2*j+d1*floor(j*t2/t1)+s;
			if(j*t1>=t2)
			f[min(h,x)]=min(f[min(h,x)],f[i]+j*t1);
			if(j*t2>=t1)
			f[min(h,y)]=min(f[min(h,y)],f[i]+j*t2);
		}
	}
	cout<<f[h]<<endl;
	return 0;
}

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

/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
    char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
    vector<char*> v({token});
    while(token = strtok(NULL,", ")) v.push_back(token);
    return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
    debug() << " [" << args.back() << ": " << H << "] ";
    args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define IOS ios::sync_with_stdio(0); cin.tie(0)
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
const ll mod=1e9+7;
const int MX=0x3f3f3f3f;
const ll maxn=1e18;

int main(){
    IOS;
    ll p1,p2,h,s,t1,t2;
    cin>>p1>>t1>>p2>>t2>>h>>s;
    vl dp(h+1,1e18);
    int i,j;
    dp[0] = 0;
    ll ans = 1e18;

    REP(j,0,h-1){
        REP(i,1,h){
            {
                ll dam = (p1 - s)*i + i*t1/t2*(p2 - s) + ((i*t1>=t2)?s:0);
                if(dam + j > h) {
                    ans = min(ans,dp[j] + i*t1);
                }else dp[dam + j] = min(dp[dam + j], dp[j] + i*t1);
            }
            {
                ll dam = (p2 - s)*i + i*t2/t1*(p1 - s) + ((i*t2>=t1)?s:0);
                if(dam + j > h) {
                    ans = min(ans,dp[j] + i*t2);
                }else dp[dam + j] = min(dp[dam + j], dp[j] + i*t2);
            }
        }
    }

    cout<<min(ans,dp[h]);
    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using ll = long long;

int main(){
    cin.tie(0)->sync_with_stdio(0);
    ll p1, t1, p2, t2;
    cin >> p1 >> t1 >> p2 >> t2;
    ll h, s; cin >> h >> s;
    if (t1 > t2) swap(p1, p2), swap(t1, t2);

    vector<__gnu_pbds::gp_hash_table<ll, ll>> mp(h+1);
    auto solve = [&](auto self, ll h, ll c1) -> ll{
        if (h <= 0) return 0;
        if (mp[h].find(c1) != mp[h].end()) return mp[h][c1];
        ll &ans = mp[h][c1];
        ans = 1e18;
        ans = min(ans, (h+(p1-s)-1) / (p1-s) * t1 - c1);
        ans = min(ans, (h+(p2-s)-1) / (p2-s) * t2);
        // sync cannons, two cases
        // 1 waits for 2
        ll shots1 = (t2+c1)/t1 - 1;
        ll nh = h - (shots1 * (p1-s)) - (p1+p2-s);
        ans = min(ans, self(self, nh, 0) + t2);

        // 2 waits for 1
        ll t = ((t2+c1+t1-1)/t1) * t1;
        shots1 = t/t1 - 1;
        nh = h - (shots1 * (p1-s)) - (p1+p2-s);
        ans = min(ans, self(self, nh, 0) + t - c1);

        // not synced, skip to cannon 2 fires once
        shots1 = (t2+c1)/t1;
        ll nc1 = (t2+c1)%t1;
        nh = h - (shots1 * (p1-s)) - (p2-s);
        ans = min(ans, self(self, nh, nc1) + t2);

        return ans;
    };
    cout << solve(solve, h, 0) << '\n';
}

/*
27
9 18    4
13      2
27      5
11
22
24

9 18 27 36 45 54 63
13 26 39 52 65

*/

// LUOGU_RID: 92512575
#include <bits/stdc++.h>
#define int long long
#define inf 0x3f3f3f3f
#define re register
#define N 601200
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;

inline int read(){
	int x=0,w=0;char ch=getchar();
	while (!isdigit(ch))w|=ch=='-',ch=getchar();
	while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return w?-x:x;
}
int f[N],ans=1e18;
void cmn(int &a,int b){a=min(a,b);}
signed main(){
	int p1=read(),t1=read(),p2=read(),t2=read(),h=read(),s=read();
	memset(f,0x3f,sizeof(f));f[0]=0;
	for (int i=0;i<=h;++i){
        for (int j=1;j<=h;++j){
			if (t1*j>=t2)cmn(f[min(h,i+(j-1)*(p1-s)+(t1*j-t2)/t2*(p2-s)+p1+p2-s)],f[i]+max(j*t1,t2));
			cmn(f[min(h,i+j*(p1-s))],f[i]+j*t1);
			if (t2*j>=t1)cmn(f[min(h,i+(j-1)*(p2-s)+(t2*j-t1)/t1*(p1-s)+p1+p2-s)],f[i]+max(j*t2,t1));
			cmn(f[min(h,i+j*(p2-s))],f[i]+j*t2);
		}
	}
	for (int i=h;i<=h+max(p1,p2);++i)
		ans=min(ans,f[i]);
	printf("%lld\n",ans);
	return 0;
}

//#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int N = 5e3 + 7;
//const int mod = 1e9 + 7;
//const double pi = acos(-1.0);
//const double E=exp(1.0);
//const double eps = 1e-8;
//#define int ll

#define PII pair<ll, ll>
#define x first
#define y second

ll h, s;
PII p[5];
ll dp[N];

void solve() {
    for (int i = 1; i <= 2; ++i) {
        scanf("%lld%lld", &p[i].x, &p[i].y);
    }
    scanf("%lld%lld", &h, &s);
    memset(dp, 0x7f, sizeof dp);
    dp[0] = 0;
    for (int i = 1; i <= h; ++i) {
        dp[i] = min(dp[max(0ll, i + s - p[1].x)] + p[1].y, dp[max(0ll, i + s - p[2].x)] + p[2].y);
        for (int j = 1; j <= i; ++j) {
            if (j * p[1].y >= p[2].y) {
                ll hurt = (j - 1) * (p[1].x - s) + (j * p[1].y - p[2].y) / p[2].y * (p[2].x - s) + p[1].x + p[2].x - s;
                dp[i] = min(dp[i], dp[max(0ll, i - hurt)] + j * p[1].y);
            }
            if (j * p[2].y >= p[1].y) {
                ll hurt = (j - 1) * (p[2].x - s) + (j * p[2].y - p[1].y) / p[1].y * (p[1].x - s) + p[1].x + p[2].x - s;
                dp[i] = min(dp[i], dp[max(0ll, i - hurt)] + j * p[2].y);
            }
        }
    }
    printf("%lld\n", dp[h]);
}

signed main() {
//    freopen("1.in","r",stdin);
    int T = 1;
//    scanf("%d", &T);
    while (T--) {
        solve();
    }
    return 0;
}

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

void test_case()
{
    array<int64_t, 2> p, t;
    int64_t h, s;
    cin >> p[0] >> t[0] >> p[1] >> t[1] >> h >> s;

    if (t[0] < t[1]) {
        swap(t[0], t[1]);
        swap(p[0], p[1]);
    }

    vector<int64_t> ans(h + 1, numeric_limits<int64_t>::max());
    ans[0] = 0;
    for (int H = 1; H <= h; ++H) {
        for (int i = 0; i < 2; ++i)
            ans[H] = min(ans[H], (H + p[i] - s - 1) / (p[i] - s) * t[i]);

        for (int j = 0; j < 2; ++j) {
            int cnt = 1;
            for (int64_t T = (t[j ^ 1] + t[j] - 1) / t[j] * t[j]; T < ans[H];
                 T += t[j]) {
                int cur = H;
                for (int i = 0; i < 2; ++i)
                    cur -= (T / t[i]) * (p[i] - s);
                cur -= cnt * s;

                if (cur < 0)
                    ans[H] = min(ans[H], T);
                else
                    ans[H] = min(ans[H], ans[cur] + T);

                if (T % t[j ^ 1] == 0)
                    ++cnt;
            }
        }
    }

    cout << ans[h] << '\n';
}

int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int Case = 1;
    // cin >> Case;
    for (int i = 1; i <= Case; i++) {
        // cout << "Case #" << i << ": ";
        test_case();
    }
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 69
#endif

typedef long long ll;
const ll inf = 1e18;
int main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL);

int p1,p2;
ll t1,t2;
int h,s;
cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
vector<ll> dp(h+1, inf);
dp[0] = 0;
// iterate over all the possible intervals between two double shots
for(int k=0; k<=h; k++){
for(int i=1; i<=h; i++){
	for(int j=0; j<2; j++) {
		ll T = (j==0 ? i*t1 : i*t2);
		ll num1 = T/t1 - 1, num2 = T/t2 - 1;
		ll damage;
		if(num1 >=0 and num2 >= 0) damage = (num1)*(p1-s) + (num2)*(p2-s) + p1 +p2 -s;
		else if(num1 >= 0) damage = (num1+1)*(p1-s);
		else if(num2 >= 0) damage = (num2+1)*(p2-s);

			if(k+damage > h) dp[h] = min(dp[h], dp[k] + T);
			else dp[k+damage] = min(dp[k+damage], dp[k] + T);
		}
	}
}
cout << dp[h] << endl;
return 0;
}

#include<bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 69
#endif

typedef long long ll;
const ll inf = 1e18;
int main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL);

int p1,p2;
ll t1,t2;
int h,s;
cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
vector<ll> dp(h+1, inf);
dp[0] = 0;
// iterate over all the possible intervals between two double shots
for(int i=1; i<=h; i++){
	for(int j=0; j<2; j++) {
		ll T = (j==0 ? i*t1 : i*t2);
		ll num1 = T/t1 - 1, num2 = T/t2 - 1;
		ll damage;
		if(num1 >=0 and num2 >= 0) damage = (num1)*(p1-s) + (num2)*(p2-s) + p1 +p2 -s;
		else if(num1 >= 0) damage = (num1+1)*(p1-s);
		else if(num2 >= 0) damage = (num2+1)*(p2-s);
		for(int k=0; k<=h; k++){
			if(k+damage > h) dp[h] = min(dp[h], dp[k] + T);
			else dp[k+damage] = min(dp[k+damage], dp[k] + T);
		}
	}
}
cout << dp[h] << endl;
return 0;
}

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

#define ll          long long
#define ld          long double
#define ii          pair<ll,ll>
#define iii         pair<ll,ii>
#define vii         vector<ii>
#define x           first
#define y           second
#define OO          (ll)1e18
#define oo          1e9
#define sz(x)       ((int)x.size())
#define vi          vector<int>
#define vvi         vector<vi>
#define vvii        vector<vii>

int dx[]={1,1,-1,-1};
int dy[]={1,-1,1,-1};

const int N=5e5+10,LOG=32,M=998244353;

ll p[2],t[2];
ll h,s;
ll dp[N];

void solve()
{
    for(int k=0;k<2;k++)cin>>p[k]>>t[k];
    cin>>h>>s;

    fill(&dp[0],&dp[h+1],OO);
    dp[0]=0;
    for(int i=0;i<h;i++)
    {
        for(int j=1;j<=h;j++)
        {
            for(int k=0;k<2;k++)
            {
                if(i+j*(p[k]-s)>=h)dp[h]=min(dp[h],dp[i]+j*t[k]);
                if (j * t[k] < t[k^1])continue;
                int ni = min(h, i + j * (p[k] - s) + j * t[k] / t[k^1] * (p[k^1] - s) + s);
                dp[ni] = min(dp[ni], dp[i] + j * t[k]);
            }
        }
    }

    cout<<dp[h]<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);

#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif

    int t=1;
//    cin>>t;
    for(int i=1;i<=t;i++)solve();
}

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

#define rep(i, a, n) for(int i=(a); i<(n); ++i)
#define per(i, a, n) for(int i=(a); i>(n); --i)
#define pb emplace_back
#define mp make_pair
#define clr(a, b) memset(a, b, sizeof(a))
#define all(x) (x).begin(),(x).end()
#define lowbit(x) (x & -x)
#define fi first
#define se second
#define lson o<<1
#define rson o<<1|1
#define gmid l[o]+r[o]>>1

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;

constexpr int mod = 998244353;
constexpr int inf = 0x3f3f3f3f;
constexpr int N = 5010;

int p1, p2, h, s;
ll t1, t2, dp[N], f[N];

void upd(ll &x, ll y){
  if(x == -1 || x > y)  x = y;
}

void _main(){
  cin >> p1 >> t1;
  cin >> p2 >> t2;
  cin >> h >> s;

  clr(dp, -1);
  clr(f, -1);
  dp[0] = 0;
  ll v1 = t1, v2 = t2;
  int c = 0;
  while(c < h){
    ll cur = min(v1, v2);
    if(v1 == v2){
      c = c + (p1 + p2 - s);
      v1 += t1;
      v2 += t2;
    } else if(v1 < v2){
      c = c + (p1 - s);
      v1 += t1;
    } else {
      c = c + (p2 - s);
      v2 += t2;
    }
    if(c > h) c = h;
    upd(dp[c], cur);
  }

  rep(i, 1, h + 1){
    rep(j, 1, h + 1){
      ll t = max(i * t1, j * t2);
      int d = (i - 1) * (p1 - s) + (j - 1) * (p2 - s) + (p1 + p2 - s);
      upd(f[min(h, d)], t);
      upd(dp[min(h, d)], t);
    }
  }

  per(i, h-1, -1) upd(dp[i], dp[i+1]);

  rep(i, 1, h){
    if(f[i] == -1)  continue;
    rep(j, 0, h - i + 1){
      upd(dp[j + i], dp[j] + f[i]);
    }
  }
  cout << dp[h] << '\n';
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  _main();
  return 0;
}

# include <bits/stdc++.h>
# define pb push_back
# define eb emplace_back
# define f first
# define s second
# define int long long
using namespace std;
set <pair <int,int>> dp[3][5001];
main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long p[3], t[3];
    long long h, S;
    cin >> p[1] >> t[1];
    cin >> p[2] >> t[2];
    cin >> h >> S;
    set <pair <pair <int,int>,pair <int,int>>> event;
    event.insert({{t[1],h},{1,0}});
    event.insert({{t[2],h},{2,0}});
    pair <pair <int,int>,pair <int,int>> state[3][5001], val, val2, i;
    int timeline[3][5001];
    int op[3];
    op[2] = op[1] = 5001;
    int cnt = 0;
    while(1){
        cnt ++;
        // if(cnt > 20){
        //     return -1;
        // }
        i = *event.begin();
        event.erase(i);
        // cout << i.f.f << ' ' << i.f.s << ' ' << i.s.f << ' ' << i.s.s << endl;
        val = {{i.f.f + t[i.s.f],i.f.s},{i.s.f, i.s.s + p[i.s.f] - S}};
        if(i.f.s <= i.s.s + p[i.s.f] - S){
            cout << i.f.f << endl;
                return 0;
        }
        bool effective = true;
        if(state[3^i.s.f][i.f.s].f.f != 0){
            val2 = state[3^i.s.f][i.f.s];
            int damage = i.s.s + val2.s.s + p[i.s.f];
            if(i.f.s <= i.s.s + val2.s.s + p[i.s.f]){
                // cout << i.f.f << ' ' << val2.s.s << ' ' << i.f.s << endl;
                cout << i.f.f << endl;
                return 0;
            }
            if(i.f.s - damage > op[i.s.f]) effective = false;
            // cout << i.f.f << ' ' << i.f.s << ' ' << op[i.s.f] << endl;
            if(effective){
                event.insert({{i.f.f + t[1],i.f.s - damage},{1, 0}});
                event.insert({{i.f.f + t[2],i.f.s - damage},{2, 0}});
                timeline[1][i.f.s - damage] = 1;
                timeline[2][i.f.s - damage] = 1;
            }
        }
        op[i.s.f] = min(op[i.s.f], val.f.s - val.s.s - state[3^i.s.f][i.f.s].s.s - S);
        if(!effective){
            timeline[i.s.f][i.f.s] = timeline[3^i.s.f][i.f.s] - 1;
        }
        if(effective)  timeline[i.s.f][i.f.s] = effective;

        if(effective || timeline[i.s.f][i.f.s] > -4){
        event.insert(val);
        state[i.s.f][i.f.s] = val;
        }
    }
}

#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
typedef pair<LL, LL> pLL;
#define ff first
#define ss second
#define show(x) cout << #x << ": " << x << "; "
#define MOD 1000000007
#define MAXN 5003

LL dp[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    LL p1, t1, p2, t2;
    LL h, s;
    LL i, j, dmg;

    cin >> p1 >> t1 >> p2 >> t2;
    cin >> h >> s;

    dp[0] = 0;
    for(i = 1; i <= h; i++)
    {
        dp[i] = min(dp[max(0LL, i - (p1-s))] + t1, dp[max(0LL, i - (p2-s))] + t2);

        for(j = 1; j <= i; j++)
        {
            if(j*t1 >= t2)
            {
                dmg = (j - 1)*(p1 - s) + (j*t1 - t2)/t2*(p2 - s) + (p1 + p2 - s);
                dp[i] = min(dp[i], dp[max(0LL, i - dmg)] + j*t1);
            }
            if(j*t2 >= t1)
            {
                dmg = (j - 1)*(p2 - s) + (j*t2 - t1)/t1*(p1 - s) + (p1 + p2 - s);
                dp[i] = min(dp[i], dp[max(0LL, i - dmg)] + j*t2);
            }
        }
    }

    cout << dp[h] << "\n";
}

#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 3e5+5;
typedef long long ll;
typedef pair<ll, ll>  pll;
typedef pair<int, int> pii;
ll dp[maxn],v[maxn],co[maxn];
using i128 = __int128;

std::istream &operator>>(std::istream &is, i128 &n) {
    n = 0;
    std::string s;
    is >> s;

    for (auto c : s) {
        n = 10 * n + c - '0';
    }
    return is;
}

std::ostream &operator<<(std::ostream &os, i128 n) {
    if (n == 0) {
        return os << 0;
    }
    std::string s;
    while (n > 0) {
        s += '0' + n % 10;
        n /= 10;
    }
    std::reverse(s.begin(), s.end());
    return os << s;
}

i128 gcd(i128 a, i128 b) {
    return b ? gcd(b, a % b) : a;
}
int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        ll p1,p2,t1,t2;
        cin>>p1>>t1;
        cin>>p2>>t2;
        ll h,s;
        if (t1>t2)
        {
        	swap(t1,t2);
        	swap(p1,p2);
        }
        cin>>h>>s;
        for (ll i=1;i<=h;++i)
        {
        	co[i]=i*t2;
        	v[i]=(p1+p2-s)+(co[i]/t1-1)*(p1-s)+(i-1)*(p2-s);
        	dp[i]=1e18;
        	//cout<<co[i]<<' '<<v[i]<<"\n";
        }
        for (ll i=1;i<=h;++i)
        {
        	co[i+h]=co[i]+(t1-co[i]%t1);
        	v[i+h]=v[i]+p1-s;
        }
        for (int i=1;i<=2*h;++i)
        {
        	for (int j=1;j<=h;++j)
        	{
        		dp[j]=min(dp[j],dp[max(0ll,j-v[i])]+co[i]);
        	}
        }
        // for (int i=0;i<=h;++i)
        // {
        // 	cout<<dp[i]<<" \n"[i==h];
        // }
        ll ans=1e18;
        for (int i=0;i<=h;++i)
        {
        	ll ot=h-i;
        	ll l=0,r=1e18,c=1e18;
        	while (l<=r)
        	{
        		ll mid=(l+r)>>1;
        		i128 can=(i128)(mid/t1)*(p1-s)+(i128)(mid/t2)*(p2-s);
        		//cout<<mid<<' '<<can<<"\n";
        		if (can>=ot)
        		{
        			c=min(c,mid);
        			r=mid-1;
        		}
        		else
        		{
        			l=mid+1;
        		}
        	}
        	ans=min(ans,dp[i]+c);
        }
        cout<<ans<<'\n';
    }
    return 0;
}
/*
3 19
4 29
11 2
*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <iomanip>
#include <sstream>
using namespace std;
#define FIO ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
const ll inf = ll(1e9) + 7;

int main()
{
	FIO
		ll p1, p2, t1, t2, h, s;
	cin >> p1 >> t1;
	cin >> p2 >> t2;
	cin >> h >> s;
	vector<ll>dp(10001, 1e18);
	vector<ll>dp2(10001, 1e18);

	dp[0] = 0;
	dp2[0] = 0;
	for (ll i = 1; i <= 10000; ++i)
	{

		for (ll j = 1; j <= 10000; ++j)
		{
			ll t = j*t1;
			ll cnt1 = t / t1 - 1;
			ll cnt2 = t / t2 - 1;

			ll x = (t / t1) * (p1 - s) + (t / t2) * (p2 - s);

			if (x <= 10000&& x >= 0)
			{
				dp2[x] = min(dp2[x], t);
			}
			if (cnt1 < 0 || cnt2 < 0)continue;
			ll y = i - cnt1 * (p1 - s) - cnt2 * (p2 - s) - p1 - p2 + s;
			if (y < 0 || y > 10000)continue;
			dp[i] = min(dp[i], dp[y] + t);
		}
		for (ll j = 1; j <= 10000; ++j)
		{
			ll t = j*t2;
			ll cnt1 = t / t1 - 1;
			ll cnt2 = t / t2 - 1;

			ll x = (t / t1) * (p1 - s) + (t / t2) * (p2 - s);

			if (x <= 10000 && x>=0)
			{
				dp2[x] = min(dp2[x], t);
			}
			if (cnt1 < 0 || cnt2 < 0)continue;
			ll y = i - cnt1 * (p1 - s) - cnt2 * (p2 - s) - p1 - p2 + s;
			if (y < 0 || y > 10000)continue;
			dp[i] = min(dp[i], dp[y] + t);
		}

	}
	ll res = 1e18;
	for(ll i = 0; i<=10000;++i)
		for (ll j = 0; j <= 10000; ++j)
		{
			if (i + j < h)continue;
			res = min(res, dp[i] + dp2[j]);
		}

	cout << res;
		return 0;
}

/*
DavitMarg
In a honky-tonk,
Down in Mexico
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <random>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#define mod 998244353ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v,l,r) v.begin(), v.end()
#define fastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

const int N = 5005;

LL p1, p2, t1, t2, h, s;
LL dp[N][N];

void solve()
{
	cin >> p1 >> t1;
	cin >> p2 >> t2;
	cin >> h >> s;

	if (t1 > t2)
	{
		swap(p1, p2);
		swap(t1, t2);
	}

	for (int i = h; i >= 0; i--)
		for (int j = 0; j <= h / (p1 - s) + 1; j++)
			dp[i][j] = mod * mod;

	dp[h][0] = 0;
	for (int i = h; i >= 1; i--)
	{
		for (LL j = 0; j <= h / (p1 - s) + 1; j++)
		{
			dp[max(0ll, i - (p1 - s))][j + 1] = min(dp[max(0ll, i - (p1 - s))][j + 1], dp[i][j] + t1);

			if (t1 * (j + 1) <= t2)
				dp[max(0ll, i - (p1 + p2 - s))][0] = min(dp[max(0ll, i - (p1 + p2 - s))][0], dp[i][j] + t2 - j * t1);
			else
			{
				LL k = ((t1 * (j + 1)) / t2) - 1;
				dp[max(0ll, i - (p1 + p2 - s) - k * (p2-s))][0] = min(dp[max(0ll, i - (p1 + p2 - s) - k * (p2 - s))][0], dp[i][j] + t1);
			}
		}
	}

	LL ans = mod * mod;

	for (int j = 0; j <= h / (p1 - s) + 1; j++)
		ans = min(ans, dp[0][j]);

	cout << ans << endl;

}

int main()
{
	fastIO;
	int T = 1;
	//cin >> T;
	while (T--)
		solve();
	return 0;
}

/*

2 15
2 19
23 1

cd /mnt/d/Davit/ProgProjects/DavitMargCP/DavitMargCP; g++ -std=c++17 -O2 -Wall -Wextra -Ddeath -Wshadow src.cpp -o orz; ./orz; rm orz

*/

// #pragma GCC target("avx2")
// #pragma GCC optimization("O3")
// #pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>

#define i64 int64_t
#define i128 i64
#define endl '\n'
#define td(x) x.begin(), x.end()
#define re(x)        \
  for (auto &_i : x) \
    cin >> _i;
#define pr(x)        \
  for (auto &_i : x) \
    cout << _i << " \n"[&_i == &x.back()];
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
// const int mod = 1e9 + 9;
// const int mod = 998244353;

const int maxn = 200200;

void solve()
{
  i64 p[2], t[2], h, s;
  for(int i=0;i<2;i++) cin >> p[i] >> t[i];
  if(t[0] > t[1]) {
    swap(t[0], t[1]);
    swap(p[0], p[1]);
  }
  cin >> h >> s;
  vector<i64> dp(h + 1);
  dp[0] = 0;
  for(int i=1;i<=h;i++){
    dp[i] = dp[max((i64)0, i-p[0]+s)] + t[0];
    for(int j=0;j<=i;j++){
      i64 d = j * (p[0] - s) + ((j * t[0]) / t[1]) * (p[1] - s);
      i64 tl = max(t[1] - ((j * t[0]) % t[1]), t[0]);
      dp[i] = min(dp[i], dp[max((i64)0, i-d-(p[0]+p[1]-s))] + j*t[0] + tl);
    }
  }
  cout << dp[h] << endl;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  int t = 1;
  // cin >> t;
  for(int i=1;i<=t;i++)
  {
    // cout << "Case #" << i << ": ";
    solve();
  }
}

#include <bits/stdc++.h>
#define ll long long
#define int long long
#define fi first
#define se second
#define mat vector<vector<ll>>
using namespace std;
void db() {cout << '\n';}
template <typename T, typename ...U> void db(T a, U ...b) {cout << a << ' ', db(b...);}
#ifdef Cloud
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define file ios::sync_with_stdio(false); cin.tie(0)
#endif
auto SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);
const int N = 2e5 + 5, mod = 998244353;
int inf = 1ll << 60;
void solve(){
    int p[2], t[2], h, s;
    cin >> p[0] >> t[0] >> p[1] >> t[1] >> h >> s;
    int dp[h + 1]{};
    for (auto &i : dp) i = inf;

    int ans = min((h + p[0] - s - 1) / (p[0] - s) * t[0],  (h + p[1] - s - 1) / (p[1] - s) * t[1]);

    for (int i = 0, cur = 0; i <= h; i += p[0] - s, cur += t[0]){
        ans = min(ans, max(cur, (h - i + p[1] - s - 1) / (p[1] - s) * t[1]));
    }

    for (int i = 1; i <= h; i++){
        int sum = (i - 1) * (p[0] - s) + (t[0] * i - t[1]) / t[1] * (p[1] - s);
        if (sum >= h) break;
        if (t[0] * i >= t[1]) dp[sum] = min(dp[sum], t[0] * i);
    }

    for (int i = 1; i <= h; i++){
        int sum = (i - 1) * (p[1] - s) + (t[1] * i - t[0]) / t[0] * (p[0] - s);
        if (sum >= h) break;
        if (t[1] * i >= t[0]) dp[sum] = min(dp[sum], t[1] * i);
    }

    for (int i = 0; i < h; i++){
        //db(i, dp[i]);
        int c[2] = {dp[i], dp[i]}, sum = i;
        c[0] += t[0], c[1] += t[1];
        sum += p[0] + p[1] - s;
        if (sum >= h) ans = min(ans, dp[i]);
        //db(i, dp[i]);
        while (sum < h){
            //db(sum, c[0], c[1]);
            int tmp1 = c[0] + ((h - sum + p[0] - s - 1) / (p[0] - s) - 1) * t[0];
            int tmp2 = c[1] + ((h - sum + p[1] - s - 1) / (p[1] - s) - 1) * t[1];
            ans = min(ans, tmp1);
            ans = min(ans, tmp2);

            dp[sum] = min(dp[sum], max(c[0], c[1]));

            if (c[0] < c[1]){
                c[0] += t[0];
                sum += p[0] - s;
            }
            else{
                c[1] += t[1];
                sum += p[1] - s;
            }
        }
    }
    db(ans);
}
signed main(){
    file;
    int t = 1;
    //cin >> t;
    while (t--) solve();
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;

template<typename T>inline void read(T&num){
    int f=1,ch=getchar();num=0;
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){num=num*10+(ch^48);ch=getchar();}
    num=num*f;
}
template<typename T>void print(T x){
    if(x<0){putchar('-');x=-x;}
    if(x>9)print(x/10);
    putchar(x%10+48);
}

const int MAXN=5005;
const ll INF=0x7fffffffffffff;
int p1,p2,h,s;
ll t1,t2,ans=INF,c[MAXN<<1],v[MAXN<<1],dp[MAXN],tot;
template<typename T>inline void Min(T&a,T b){if(a>b)a=b;}

bool check(ll t,ll rem){
    ll tim1=t/t1,tim2=t/t2;
    return tim1*(p1-s)+tim2*(p2-s)>=rem;
}
ll solve(ll rem){
    if(!rem)return 0;
    ll l=0,r=(((ll)rem-1)/(p1-s)+1)*t1;
    while(l+1<r){
        ll mid=((l+r)>>1);
        if(check(mid,rem))r=mid;
        else l=mid;
    }
    return r;
}

int main(){
    read(p1);read(t1);read(p2);read(t2);read(h);read(s);
    ans=solve(h);
    for(int i=1;i<=h;i++)dp[i]=INF;
    for(int i=1;i*(p1-s)<=h+p1-s;i++){
        ll tim=t1*i,ls2=tim/t2;
        if(!ls2)continue;
        ll dam=i*(p1-s)+ls2*(p2-s)+s;
        tot++;c[tot]=tim;v[tot]=min((ll)h,dam);
    }
    for(int i=1;i*(p2-s)<=h+p2-s;i++){
        ll tim=t2*i,ls1=tim/t1;
        if(!ls1)continue;
        ll dam=i*(p2-s)+ls1*(p1-s)+s;
        tot++;c[tot]=tim;v[tot]=min((ll)h,dam);
    }dp[0]=0;
    for(int i=1;i<=tot;i++){
        for(ll j=1;j<=h;j++)Min(dp[j],dp[max(0ll,j-v[i])]+c[i]);
    }
    for(int i=0;i<=h;i++){
        Min(ans,dp[i]+solve(h-i));
    }
    cout<<ans<<'\n';
    return 0;
}

// DABC ABCD ABCA DBAA
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
using ll=long long;
using pli=pair<ll,int>;
using pi=pair<int,int>;
template<typename A>
using vc=vector<A>;
inline int read()
{
	int s=0,w=1;char ch;
	while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1;
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
inline ll lread()
{
	ll s=0,w=1;char ch;
	while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1;
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
ll dp1[5001];
ll dp2[5001];
int p1,p2;
ll t1,t2;
int h,s;
ll cal1(ll tim)
{
	if(tim<t1||tim<t2) return 0;
	ll num1=tim/t1-1,num2=tim/t2-1;
	if(p1!=s&&num1>h) return inf;
	if(p2!=s&&num2>h) return inf;
	return num1*(p1-s)+num2*(p2-s)+(p1+p2-s);
}
ll cal2(ll tim)
{
	ll num1=tim/t1,num2=tim/t2;
	if(p1!=s&&num1>h) return inf;
	if(p2!=s&&num2>h) return inf;
	return num1*(p1-s)+num2*(p2-s);
}
ll check1(int hp)
{
	ll ans=-1;
	for(ll i=1ll<<52;i;i>>=1) if(cal1(ans+i)<hp) ans+=i;
	return ans+1;
}
ll check2(int hp)
{
	ll ans=-1;
	for(ll i=1ll<<52;i;i>>=1) if(cal2(ans+i)<hp) ans+=i;
	return ans+1;
}
int main()
{
	p1=read(),t1=lread();
	p2=read(),t2=lread();
	h=read(),s=read();
	memset(dp1,0x3f,sizeof(dp1)),dp1[0]=0;
	memset(dp2,0x3f,sizeof(dp2)),dp2[0]=0;
	for(int i=1;i<=h;i++)
	{
		// printf("%3lld : ",dp1[i]);
		dp1[i]=check1(i);
		for(int j=1;j<i;j++) dp1[i]=min(dp1[i],dp1[j]+dp1[i-j]);
		dp2[i]=check2(i);
		// printf("%d : %3lld %3lld\n",i,dp1[i],dp2[i]);
	}
	ll ans=0x3f3f3f3f3f3f3f3fll;
	for(int i=0;i<=h;i++) ans=min(ans,dp1[i]+dp2[h-i]);
	printf("%lld\n",ans);
	return 0;
}

#include <bits/stdc++.h>

#define f first
#define s second

#define mp make_pair

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll M;

ll DP[10001][5001];

vector<ll> cringe;
vector<ll> damage;
ll lim = -1;

ll P1; ll T1;
ll P2; ll T2;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    if (a < b) return gcd(b,a);
    return gcd(b,a%b);
}

int main() {
    cin >> P1; cin >> T1;
    cin >> P2; cin >> T2;
    ll H, S;
    cin >> H >> S;

    P1 -= S; P2 -= S;

    ll C = P1 + P2 + S;
    ll T = max(T1,T2);

    cringe.push_back(0);
    damage.push_back(0);

    M = 5001;
    bool special = 0;
    ll g = gcd(T1,T2);
    if (T1/g < 10000 && T2/g < 10000) {
        M = min(M, (T1+T2-1)/gcd(T1,T2));
        special = ((T1+T2-1)/gcd(T1,T2) <= 5000);
    }

    ll ct1 = 1;
    ll ct2 = 1;

    while (cringe.size() != M) {
        if (T1*ct1 < T2*ct2) cringe.push_back(T1*(ct1++));
        else cringe.push_back(T2*(ct2++));
        damage.push_back(P1*ct1+P2*ct2-P1-P2);
    }

    int MD = 9999999;
    ll xdf = T1*T2/gcd(T1,T2);
    //if (special) MD = (xdf/T1)*P1 + (xdf/T2)*P1 -

    for (int i = 0; i <= 10000; i++) {
        for (int j = 0; j <= 5000; j++) {
            DP[i][j] = 1ll<<60;
        }
    }

    /*for (int i = 0; i < M; i++) {
        cout << cringe[i] << " " << damage[i] << endl;
    }*/

    DP[H+5000][0] = 0;

    ll ret = DP[0][0];
    for (int i = 5000+H-1; i >= 0; --i) {
        if (i <= 5000+H-C) {
            DP[i][0] = min(DP[i][0],DP[i+C][0]+T);
            for (int k = 1; k < M; k++) {
                if (cringe[k]%T1==0)
                DP[i][0] = min(DP[i][0],DP[i+C][k]+max(T1,T2+cringe[k]/T2*T2-cringe[k]));
                else
                DP[i][0] = min(DP[i][0],DP[i+C][k]+max(T2,T1+cringe[k]/T1*T1-cringe[k]));
            }
        }
        //if (i <= )
        for (int j = 1; j < M; j++) {
            if (i <= 5000+H-damage[j]+damage[j-1])
                DP[i][j] = min(DP[i][j],DP[i+damage[j]-damage[j-1]][j-1]+cringe[j]-cringe[j-1]);
            if (i<=5000) ret = min(ret,DP[i][j]);
        }
        if (i<=5000) ret = min(ret,DP[i][0]);
    }
    /*for (int i = 5000+H; i >= 0; --i) {
        cout << i << ":\t";
        for (int j = 0; j < M; j++) {
            if (DP[i][j]>5000) cout <<"";
            else cout << DP[i][j] << "\t";
        }
        cout << endl;
    }*/
    cout << ret << endl;
}

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <ciso646>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <array>
#include <bitset>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <complex>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <limits>
#include <locale>
#include <numeric>
#include <regex>
#include <string>
#include <utility>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <random>
#include <memory>
#include <chrono>
using namespace std;
const unsigned long long inf = 1e18;
#define MAXN 301
#define pb push_back
#define mp make_pair
using ll = long long;
#define int long long
#define endl '\n'
#define ff first
#define ss second
void fast_stream() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll p1, t1;
ll h, s;
ll p2, t2;
ll ans = inf;

void solve() {
    cin >> p1 >> t1;
    cin >> p2 >> t2;
    cin >> h >> s;
    if (t1 > t2) {
        swap(t1, t2);
        swap(p1, p2);
    }
    vector<ll> dp(h + 5001, inf);
    dp[0] = 0;
    for (int i = 1; i <= h; i++) {
        set<pair<ll, ll>> sp;
        ll kol = 0;
        for (int w = 1; w <= i; w++) {
            sp.insert(mp(w * t1, 1));
            while ((kol + 1) * t2 <= w * t1) {
                sp.insert(mp((kol + 1) * t2, 2));
                kol++;
            }
            if (sp.size() >= i) {
                break;
            }
        }
        ll last1 = 0, last2 = 0, tim = 0;
        ll d = 0;
        while (sp.size() > 0) {
            auto y = *sp.begin();
            sp.erase(sp.begin());
            ll d1 = d + ((p1 + p2) - s);
            ll tim_need = max(last1 + t1, last2 + t2);
            dp[i] = min(dp[i], dp[max(0LL, i - d1)] + tim_need);
            tim = y.ff;
            if (y.ss == 1) {
                last1 = tim;
                d += (p1 - s);
            } else {
                last2 = tim;
                d += (p2 - s);
            }
            if (d >= i) {
                dp[i] = min(dp[i], tim);
                break;
            }
        }
    }
    ll ans = inf;
    for (int i = h; i <= h; i++) {
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
}

signed main() {
    fast_stream();
    ll t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <ciso646>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <array>
#include <bitset>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <complex>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <limits>
#include <locale>
#include <numeric>
#include <regex>
#include <string>
#include <utility>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <random>
#include <memory>
#include <chrono>
using namespace std;
const unsigned long long inf = 1e18;
#define MAXN 301
#define pb push_back
#define mp make_pair
using ll = long long;
#define int long long
#define endl '\n'
#define ff first
#define ss second
void fast_stream() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll p1, t1;
ll h, s;
ll p2, t2;
ll ans = inf;

void solve() {
    cin >> p1 >> t1;
    cin >> p2 >> t2;
    cin >> h >> s;
    vector<ll> dp(h + 5001, inf);
    dp[0] = 0;
    for (int i = 1; i <= h; i++) {
        set<pair<ll, ll>> sp;
        for (int j = 1; j <= i; j++) {
            sp.insert(mp(t1 * j, 1));
        }
        for (int j = 1; j <= i; j++) {
            sp.insert(mp(t2 * j, 2));
        }
        ll last1 = 0, last2 = 0, tim = 0;
        ll d = 0;
        while (sp.size() > 0) {
            auto y = *sp.begin();
            sp.erase(sp.begin());
            ll d1 = d + ((p1 + p2) - s);
            ll tim_need = max(last1 + t1, last2 + t2);
            dp[i] = min(dp[i], dp[max(0LL, i - d1)] + tim_need);
            tim = y.ff;
            if (y.ss == 1) {
                last1 = tim;
                d += (p1 - s);
            } else {
                last2 = tim;
                d += (p2 - s);
            }
            if (d >= i) {
                dp[i] = min(dp[i], tim);
                break;
            }
        }
    }
    ll ans = inf;
    for (int i = h; i <= h; i++) {
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
}

signed main() {
    fast_stream();
    ll t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

#include<bits/stdc++.h>

#define ll long long
#define get(x) int x; cin >> x;
#define gett(x,type) type x; cin >> x;
#define forn(i, x) for(int i = 0; i < x; i++)

using namespace std;

int main(){
	get(p1); gett(t1, ll);
	get(p2); gett(t2, ll);
	get(h); get(s);

	vector<ll> dp(h+1, 100000000000000000);
	dp[0] = 0;
	forn(i, h){
		ll t = ((ll)((t2-1)/t1)+1)*t1;
		while (true){
			ll d = p1+p2-s + (ll)((t-t1)/t1)*(p1-s) + (ll)((t-t2)/t2)*(p2-s);

			if (i + d > h){
				dp[h] = min(t+dp[i], dp[h]);
				break;
			}

			dp[i+d] = min(t+dp[i], dp[i+d]);
			t += t1;
		}

		t = ((ll)((t1-1)/t2)+1)*t2;
		while (true){
			ll d = p1+p2-s + (ll)((t-t1)/t1)*(p1-s) + (ll)((t-t2)/t2)*(p2-s);

			if (i + d > h){
				dp[h] = min(t+dp[i], dp[h]);
				break;
			}

			dp[i+d] = min(t+dp[i], dp[i+d]);
			t += t2;
		}
	}

	ll t = dp[h];
	forn(i, h){
		ll new_t = t1;
		while (true){
			int d = int(new_t/t1)*(p1-s) + int(new_t/t2)*(p2-s);

			if (d+i >= h){
				break;
			}

			new_t += t1;
		}

		t = min(t, dp[i]+new_t);

		new_t = t2;
		while (true){
			int d = int(new_t/t1)*(p1-s) + int(new_t/t2)*(p2-s);

			if (d+i >= h){
				break;
			}

			new_t += t2;
		}

		t = min(t, dp[i]+new_t);
	}

	cout << t;
}

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb(x) push_back(x)
#define mem(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define rep(i,n,m) for(int i=n;i<=m;i++)
#define per(i,n,m) for(int i=n;i>=m;i--)
#define repp(i,n) for(int i=0;i<n;i++)
#define bug1(i) cout<<i<<endl
#define bug2(i,j) cout<<i<<" "<<j<<endl
#define bug3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl
#define bug4(i,j,k,l) cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl
#define mod 1000000007 //998244353.1000000007
#define maxn 300005
#define eps 1e-6
#define pi acos(-1)
using namespace std;

ll dp[maxn],d[2],t[2],h,s;

ll cal_damage(ll T){
	ll da1=0,da2=0;
	if(T>=t[0]) da1=(T-t[0])/t[0]*(d[0]-s)+d[0];
	if(T>=t[1]) da2=(T-t[1])/t[1]*(d[1]-s)+d[1];
	return da1+da2-s;
}

void solve(){
	mem(dp,INF);
	cin>>d[0]>>t[0]>>d[1]>>t[1];
	cin>>h>>s;
	dp[0]=0;

	rep(i,1,h){
		// dp[i]
		rep(k,0,1){
			rep(j,1,h){
				ll T=j*t[k];
				ll da=cal_damage(T);
				dp[i]=min(dp[i],dp[max(0LL,i-da)]+T);
			}
		}
//		bug2(i,dp[i]);
	}
	cout<<dp[h]<<endl;
}

/**/
int main(){
	ios::sync_with_stdio(false);
//	int ca;cin>>ca;while(ca--)
	solve();
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p1,p2,t1,t2,s;
ll dp[5009];
bool ch(ll x,ll y)
{
    ll u=(x/t1);
    if(u>=y)return true;
    ll res=u*(p1-s);
    u=(x/t2);
    if(u>=y)return true;
    res+=u*(p2-s);
    return (res>=y);
}
ll go(ll u)
{
    if(u<=0)return 0;
    if(dp[u]!=-1)return dp[u];
    ll l=0,r=100000000000000000;
    while(l<r)
    {
        ll mid=(l+r)/2;
        if(ch(mid,u))r=mid;
        else l=mid+1;

    }
    dp[u]=l;
    for(int i=1;i<=5000;i++)
    {
     ll gg=i*t1;
     if(gg<t2)continue;
     ll z=u-(i-1)*(p1-s);
     ll d=(gg-t2)/t2;
     if(d>u){dp[u]=min(dp[u],gg);break;}
     z-=d*(p2-s);
     z-=(p1+p2-s);
     if(z<0){dp[u]=min(dp[u],gg);break;}
     dp[u]=min(dp[u],gg+go(z));
    }

    for(int i=1;i<=5000;i++)
    {
     ll gg=i*t2;
     if(gg<t1)continue;
     ll z=u-(i-1)*(p2-s);
     ll d=(gg-t1)/t1;
     if(d>u){dp[u]=min(dp[u],gg);break;}
     z-=d*(p1-s);
     z-=(p1+p2-s);
     if(z<0){dp[u]=min(dp[u],gg);break;}
     dp[u]=min(dp[u],gg+go(z));
    }
    return dp[u];
}
ll h;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>p1>>t1>>p2>>t2>>h>>s;
    memset(dp,-1,sizeof dp);
    cout<<go(h);

    return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb(x) push_back(x)
#define mem(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define rep(i,n,m) for(int i=n;i<=m;i++)
#define per(i,n,m) for(int i=n;i>=m;i--)
#define repp(i,n) for(int i=0;i<n;i++)
#define bug1(i) cout<<i<<endl
#define bug2(i,j) cout<<i<<" "<<j<<endl
#define bug3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl
#define bug4(i,j,k,l) cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl
#define mod 1000000007 //998244353.1000000007
#define maxn 300005
#define eps 1e-6
#define pi acos(-1)
using namespace std;

ll dp[maxn],d1,d2,t1,t2,h,s;

ll cal_damage(ll t){
	ll da1=0,da2=0;
	if(t>=t1) da1=(t-t1)/t1*(d1-s)+d1;
	if(t>=t2) da2=(t-t2)/t2*(d2-s)+d2;
	return da1+da2-s;
}

void solve(){
	mem(dp,INF);
	cin>>d1>>t1>>d2>>t2;
	cin>>h>>s;
	dp[0]=0;

	rep(i,1,h){
		// dp[i]
		rep(j,1,h){
			ll T=j*t1;
			ll da=cal_damage(T);
			dp[i]=min(dp[i],dp[max(0LL,i-da)]+T);
			if(da<=i){
				dp[i]=min(dp[i],dp[i-da]+T);
			}
		}

		rep(j,1,h){
			ll T=j*t2;
			ll da=cal_damage(T);
			dp[i]=min(dp[i],dp[max(0LL,i-da)]+T);
			if(da<=i){
				dp[i]=min(dp[i],dp[i-da]+T);
			}
		}
//		bug2(i,dp[i]);
	}
//	ll ans=LINF;
//	rep(i,0,h){
//		ans=min(ans,min(dp[i]+(h-i)/(d1-s)*t1,dp[i]+(h-i)/(d2-s)*t2));
//	}
//	cout<<ans<<endl;
	cout<<dp[h]<<endl;
}

/**/
int main(){
	ios::sync_with_stdio(false);
//	int ca;cin>>ca;while(ca--)
	solve();
	return 0;
}

// Problem: E. FTL
// Contest: Educational Codeforces Round 137 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1743/problem/E
// Memory Limit: 512 MB
// Time Limit: 4000 ms

// last update: 2022/10/26

//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define fq(i,a,b) for (int i = (a); i <= (b); i++)
#define fnq(i,a,b) for (int i = (a); i < (b); i++)
#define nfq(i,a,b) for (int i = (a); i >= (b); i--)
#define nfnq(i,a,b) for (int i = (a); i > (b); i--)
#define fqs(i,a,b,c) for (int i = (a); i <= (b); i += (c))
#define fnqs(i,a,b,c) for (int i = (a); i < (b); i += (c))
#define nfqs(i,a,b,c) for (int i = (a); i >= (b); i -= (c))
#define nfnqs(i,a,b,c) for (int i = (a); i > (b); i -= (c))
#define elif else if
#define LAY
//#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define EBUG
#endif
#ifdef EBUG
//#undef EBUG
#endif
#ifdef EBUG
#define DEBUG if (1)
#define NDEBUG if (0)
#else
#define DEBUG if (0)
#define NDEBUG if (1)
#endif
#define McasesT int T = d; while (T--)
#define Mcases(T) int T = d; while (T--)
using namespace std;

#define int long long

//#define GRAPH
//const int EDGES = -1;
//const int VERTEXES = -1;
////# define EDGE_W
////typedef int W_TYPE;

//#define FileIO

#if !defined(LAY) || defined(FileIO)
const string FileIOName = "1";
int FILEIO (string IN, string OUT) {
    try {
        freopen ((FileIOName + IN).c_str (), "r", stdin);
        freopen ((FileIOName + OUT).c_str (), "w", stdout);
        return 0;
    } catch (int) {
        return -1;
    }
}
int freFILEIO = FILEIO (".in", ".out");
#endif

inline int rd () {
	int f = 1;
	char ch = getchar ();
	while (!isdigit (ch)) (ch == '-' ? (f = -1) : 0), ch = getchar ();
	int num = 0;
	while (isdigit (ch)) num = num * 10 + ch - '0', ch = getchar ();
	return num * f;
}
#define d rd ()

inline int rd (const int modp) {
	int f = 1;
	char ch = getchar ();
	while (!isdigit (ch)) (ch == '-' ? (f = -1) : 0), ch = getchar ();
	int num = 0;
	while (isdigit (ch)) num = (num * 10 + ch - '0') % modp, ch = getchar ();
	return (num * f % modp + modp) % modp;
}

#ifdef GRAPH
struct Edge {
	int v, nxt;
# ifdef EDGE_W
	W_TYPE w;
# endif
	Edge () {}
# ifdef EDGE_W
	Edge (int _v, W_TYPE _w, int _nxt) {v = _v, w = _w, nxt = _nxt;}
# else
	Edge (int _v, int _nxt) {v = _v, nxt = _nxt;}
# endif
} edge[EDGES];
int head[VERTEXES], ecnt;
# ifdef EDGE_W
void addedge (int u, int v, W_TYPE w) {edge[++ecnt] = Edge (v, w, head[u]); head[u] = ecnt;}
void addEdge (int u, int v, W_TYPE w) {addedge (u, v, w), addedge (v, u, w);}
#  define fe(u) for (int i = head[u], v, w; v = edge[i].v, w = edge[i].w, i; i = edge[i].nxt)
# else
void addedge (int u, int v) {edge[++ecnt] = Edge (v, head[u]); head[u] = ecnt;}
void addEdge (int u, int v) {addedge (u, v), addedge (v, u);}
#  define fe(u) for (int i = head[u], v; v = edge[i].v, i; i = edge[i].nxt)
# endif
void init () {memset (head, 0, sizeof head); ecnt = 0;}
#endif

namespace lay::CPX {
    class cpx {
        public:
            double a, b;
            cpx () {a = 0, b = 0;}
            cpx (double _a) {a = _a, b = 0;}
            cpx (double _a, double _b) {a = _a, b = _b;}
            friend cpx operator + (cpx a, cpx b) {return cpx (a.a + b.a, a.b + b.b);}
            friend cpx operator - (cpx a, cpx b) {return cpx (a.a - b.a, a.b - b.b);}
            friend cpx operator * (cpx a, cpx b) {return cpx (a.a * b.a - a.b * b.b, a.b * b.a + a.a * b.b);}
            friend cpx operator / (cpx a, cpx b) {return cpx ((a.a * b.a + a.b * b.b) / (b.b * b.b + b.a * b.a), (a.b * b.a - a.a * b.b) / (b.b * b.b + b.a * b.a));}
            friend cpx& operator += (cpx &a, cpx b) {return a = a + b;}
            friend cpx& operator -= (cpx &a, cpx b) {return a = a - b;}
            friend cpx& operator *= (cpx &a, cpx b) {return a = a * b;}
            friend cpx& operator /= (cpx &a, cpx b) {return a = a / b;}
    };
}

inline void Write (int x) {
	if (x < 0) putchar ('-'), x *= -1;
	if (x >= 10) Write (x / 10);
	putchar (x % 10 + '0');
}
template <typename T> void write (char sep, char end, T x) {Write (x); putchar (end);}
template <typename T, typename... Ts> void write (char sep, char end, T x, Ts... xs) {Write (x); putchar (sep); write (sep, end, xs...);}
template <typename... Ts> void output (Ts... xs) {write (' ', '\n', xs...);}

namespace lay::MATH {
    template <typename T = int>
    class _Math {
    public:
        static T exmax (T x) {return x;}
        template <typename... Ts> static T exmax (T x, Ts... xs) {return max (x, exmax (xs...));}
        static T exmin (T x) {return x;}
        template <typename... Ts> static T exmin (T x, Ts... xs) {return min (x, exmin (xs...));}
        template <typename... Ts> static T exgmax (T &x, Ts... xs) {return x = exmax (x, xs...);}
        template <typename... Ts> static T exgmin (T &x, Ts... xs) {return x = exmin (x, xs...);}

        static T gcd (T a, T b) {return !b ? a : gcd (b, a % b);}
        static T lcm (T a, T b) {return a / gcd (a, b) * b;}
        static T exgcd (T a, T b, T& x, T& y) {
            if (!b) {x = 1; y = 0; return a;}
            T ans = exgcd (b, a % b, y, x);
            y -= a / b * x;
            return ans;
        }
        static T crt (size_t n, T *a, T *p) {
            T M = 1, ans = 0;
            fq (i, 1, n) M *= p[i];
            fq (i, 1, n) {
                T m = M / p[i];
                T x, y;
                exgcd (m, p[i], x, y);
                ans += (x < 0 ? x + p[i] : x) * a[i] * m;
            } return ans % M;
        }
        static T excrt (size_t n, T *a, T *b) {
            T M = b[1], ans = a[1];
            fq (i, 2, n) {
                T aa = M, c = (a[i] - ans % b[i] + b[i]) % b[i];
                T x, y;
                T gcd = exgcd (aa, b[i], x, y);
                if (c % gcd) return -1;
                T bg = b[i] / gcd;
                x = c / gcd * x % bg;
                ans += x * M;
                M *= bg;
                ans = (ans % M + M) % M;

            }
            return (ans % M + M) % M;
        }
        static T power (T a, T b, T p) {
            T c = 1;
            while (b) {
                if (b & 1) c = c * a % p;
                a = a * a % p;
                b >>= 1;
            } return c;
        }
    private:
        static T C (T n, T m, T p) {
            T ans = 1;
            fq (i, n - m + 1, n) ans = ans * i % p;
            fq (i, 2, m) ans = ans * power (i, p - 2, p) % p;
            return ans;
        }
    public:
        static T lucas (T n, T m, T p) {
            if (!m || !n) return 1;
            return lucas (n / p, m / p, p) * C (n % p, m % p, p) % p;
        }
        static T bsgs (T a, T b, T p) {
            T mul = 1, t = sqrt (p) + 1;
            static map <T, T> mp;
            mp.clear ();
            fq (i, 1, t) {
                mul = mul * a % p;
                mp[b * mul % p] = i;
            }
            T mull = mul;
            fq (i, 1, t) {
                if (mp[mull]) return i * t - mp[mull];
                mull = mull * mul % p;
            } return -1;
        }
    };
    const _Math <> iMath;
    auto Math = iMath;
}

namespace lay::EXMATH {
    template <typename T = int>
    class _ExMath {
    private:
        static void expr_skpop (stack <char> &sk1, stack <T> &sk2, T fun (T, T, char)) {
            T r = sk2.top (); sk2.pop ();
            T l = sk2.top (); sk2.pop ();
            char op = sk1.top (); sk1.pop ();
            sk2.push (fun (l, r, op));
        }
    public:
        static T expr (string s, map <char, short> mp, T fun (T, T, char)) {
            static stack <char> sk1;
            static stack <T> sk2;
            while (!sk1.empty ()) sk1.pop ();
            while (!sk2.empty ()) sk2.pop ();
            s = '(' + s + ')';
            int len = s.size ();
            fnq (i, 0, len) {
                if (isdigit (s[i])) {
                    T num = 0;
                    while (isdigit (s[i])) num = num * 10 + s[i] - '0', ++i;
                    --i;
                    sk2.push (num);
                } elif (s[i] == '(') {
                    sk1.push ('(');
                } elif (s[i] == ')') {
                    while (sk1.top () != '(')
                        expr_skpop (sk1, sk2, fun);
                    sk1.pop ();
                } else {
                    while (!sk1.empty () && sk1.top () != '(' && mp[sk1.top ()] >= mp[s[i]])
                        expr_skpop (sk1, sk2, fun);
                    sk1.push (s[i]);
                }
            }
            return sk2.top ();
        }
    };
    const _ExMath <> iExMath;
    auto ExMath = iExMath;
}

namespace lay::MODINT {
    using namespace lay::MATH;
    int Eular (int x) {
        int sqrtx = sqrt (x);
        int ans = x;
        fq (i, 2, sqrtx) if (x % i == 0) {
            ans = ans / i * (i - 1);
            while (x % i == 0) x /= i;
        } if (x > 1) ans = ans / x * (x - 1);
        return ans;
    }
    template <int p>
    class Modint {
        private:
            const static int eular = Eular (p);
            int num;
            static int unsave_constructor (int x) {return (x % p + p) % p;}
        public:
            int toInt () {return num;}
            Modint () {}
            Modint (int x) {num = unsave_constructor (x);}
            friend Modint operator + (Modint a, Modint b) {int c = a.num + b.num; if (c >= p) c -= p; return Modint (c);}
            friend Modint operator - (Modint a, Modint b) {int c = a.num - b.num; if (c < 0) c += p; return Modint (c);}
            friend Modint operator * (Modint a, Modint b) {return Modint <p> :: unsave_constructor (a.num * b.num);}
            friend Modint operator / (Modint a, Modint b) {return Modint <p> :: unsave_constructor (a.num * Math.power (b.num, p - 2, p));}
            friend Modint operator ^ (Modint a, Modint b) {return Math.power (a.num, b.num % Modint <p> :: eular, p);}
            friend Modint& operator += (Modint &a, Modint b) {return a = a + b;}
            friend Modint& operator -= (Modint &a, Modint b) {return a = a - b;}
            friend Modint& operator *= (Modint &a, Modint b) {return a = a * b;}
            friend Modint& operator /= (Modint &a, Modint b) {return a = a / b;}
            friend Modint& operator ^= (Modint &a, Modint b) {return a = a ^ b;}
            Modint& operator ++ () {*this += 1; return *this;}
            Modint operator ++ (int) {Modint cpy = *this; ++(*this); return cpy;}
            Modint& operator -- () {*this -= 1; return *this;}
            Modint operator -- (int) {Modint cpy = *this; --(*this); return cpy;}
            friend istream& operator >> (istream& in, Modint x) {x = rd (p); return in;}
            friend ostream& operator << (ostream&out, Modint x) {out << x.toInt (); return out;}
    };
}
using namespace lay;
int p1 = d, t1 = d, p2 = d, t2 = d, h = d, s = d;
const int maxn = 20050;
int dp[maxn], c[maxn];
int get (int x1, int x2, int q) {
	int l = max (x1, x2), r = 1e16, ans = -1;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if ((mid - x1) / t1 * (p1 - s) + (mid - x2) / t2 * (p2 - s) < q) l = mid + 1;
		else ans = mid, r = mid - 1;
	} return ans;
}
signed main () {
    memset (dp, 0x3f, sizeof dp);
    fq (i, p1 + p2 - s, h + p1 + p2 - s) c[i] = get (t1, t2, i - p1 - p2 + s);
    dp[0] = 0;
    fq (i, 1, h + p1 + p2 - s) {
    	fq (j, 0, i - p1 - p2 + s) {
    		dp[i] = min (dp[i], dp[j] + c[i - j]);
    	}
    }
    int ans = 1e18;
    fq (i, h, h + p1 + p2 - s) ans = min (ans, dp[i]);
    fnq (i, 0, h) ans = min (ans, dp[i] + get (0, 0, h - i));
	cout << ans;
	return 0;
}

#include <bits/stdc++.h>

using i64 = long long;

int main() {
    // freopen("data.in", "r", stdin);
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int p1, p2, h, s;
    i64 t1, t2;

    std::cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

    std::vector<i64> dp(h + 1);
    dp[0] = 0;
    for (int i = 1; i <= h; i++) {
        dp[i] = std::min(dp[std::max(0, i - (p1 - s))] + t1, dp[std::max(0, i - (p2 - s))] + t2);
        for (int j = 1; j <= i; j++) {
            if (j * t1 >= t2) {
                i64 dmg = (j - 1) * (p1 - s) + (j * t1 - t2) / t2 * (p2 - s) + (p1 + p2 - s);
                dp[i] = std::min(dp[i], dp[std::max(0LL, i - dmg)] + j * t1);
            }
            if (j * t2 >= t1) {
                i64 dmg = (j - 1) * (p2 - s) + (j * t2 - t1) / t1 * (p1 - s) + (p1 + p2 - s);
                dp[i] = std::min(dp[i], dp[std::max(0LL, i - dmg)] + j * t2);
            }
        }
    }
    std::cout << dp[h] << "\n";

    return 0;
}

// LUOGU_RID: 91690650
#include<iostream>
#include<cstdio>
#include<algorithm>

#define int long long
#define N 5008
#define fo(a,b,c,d) for(int a=b;a<=c;a+=d)
#define ro(a,b,c,d) for(int a=b;a>=c;a-=d)
#define INF 9999999999999999

using namespace std;

struct Laser
{
	int p,t;
}las1,las2;

int h,s;

int f[N][2];

int ceil(int a,int b)
{
	return (a+b-1)/b;
}

int calc(int t)
{
	return (t/las1.t)*(las1.p-s)+(t/las2.t)*(las2.p-s);
}

void work()
{
	cin>>las1.p>>las1.t>>las2.p>>las2.t>>h>>s;
	fo(i,1,h,1)
	{
		fo(j,0,i-1,1)
		{
			int time=(i-j)*las1.t;
			f[i][0]=max(f[i][0],f[j][0]+(i-j)*(las1.p-s)+(time/las2.t)*(las2.p-s)+s*((time/las2.t)?1:0));
		}
		fo(j,0,i-1,1)
		{
			int time=(i-j)*las2.t;
			f[i][1]=max(f[i][1],f[j][1]+(i-j)*(las2.p-s)+(time/las1.t)*(las1.p-s)+s*((time/las1.t)?1:0));
		}
	}
	int ans=INF;
	fo(i,0,h,1)
	{
		fo(j,0,h,1)
		{
			int lst=h-f[i][0]-f[j][1],help=i*las1.t+j*las2.t;
			if(lst<0)
			{
				ans=min(ans,help);
				break;
			}
			int l=0,r=lst*las1.t,t=0;
			while(l<=r)
			{
				int mid=(l+r)>>1;
				if(calc(mid)>=lst)t=mid,r=mid-1;
				else l=mid+1;
			}
			ans=min(ans,help+t);
		}

	}
	cout<<ans<<endl;
	return;
}

signed main()
{
	cin.tie(0),cout.tie(0);
	ios::sync_with_stdio(false);
	work();
	return 0;
}
/*
It's so fucking deep
Move your tongue around more
*/

//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define int long long
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//indexed_set s;
//#define pii pair<int,int>
//#define ll long long
//#define int unsigned int
//#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define countbit(x) __builtin_popcountll( x )
//#define lb lower_bound
//#define ub upper_bound
//#define bs binary_search
#define mod 1000000007 // mod+2
#define double long double
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
const int inf=1e18;
const int N=200005;
//int d;
//vector <int> fac(N);
//vector <int> adj[N];
//vector <int> vis(N);
//vector <vector <int>> v(N);

void google(int t){
    cout<<"Case #"<<t<<": ";
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int gcd(int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}

vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
/*
void dfs(int s){
    if(vis[s])return;
    vis[s]=1;
    for(auto u:adj[s]){
        dfs(u);
    }
}
int ncr(int n, int r){
    int x=(fac[r]*fac[n-r]);
    x=inv(fac[n],x);
    return x;
}
*/
int fun(int a,int b){
    if(b==0)return 1;
    else if(a==1)return 1;
    int temp=fun(a,b/2)%mod;
    temp=(temp*temp)%mod;
     if(b%2==1)temp=(temp*a)%mod;
    return temp%mod;
}

int inv(int a,int b){
    return (a*fun(b,mod-2))%mod;
}

void solve(){
    int i,j,k=0,n,m,l=0;
    int p1,t1,p2,t2,h,s;

    cin>>p1>>t1;
    cin>>p2>>t2;
    cin>>h>>s;
    /*
    for(i=0;i<=n;i++)vis[i]=0;
    for(i=0;i<=n;i++){
         adj[i].clear();
    }
    */
    /*string s;
    cin>>s;
    n=s.length();*/
    vector <int> dp(h+1,inf);
    dp[0]=0;
    int ans=inf;

    for(int rem=1;rem<=h;rem++){
        for(i=0;(i/t1)*(p1-s)<=(h-rem+1);i+=t1){
            int l1=(i/t1)*(p1-s), l2=(max(0ll,i+t1-t2)/t2)*(p2-s), l3=(i/t2)*(p2-s);
            //cout<<i<<" "<<l1+l3<<"\n";

            if(l1+l3>=h-rem+1){
                //cout<<dp[rem-1]<<"\n";
                ans=min(ans,dp[rem-1]+i);
            }
            //cout<<ans<<"\n";
            if(1&&(i+t1>=t2)){
                dp[min(h,rem-1+l1+l2+p1+p2-s)]=min(dp[min(h,rem-1+l1+l2+p1+p2-s)],dp[rem-1]+i+t1);
            }
        }
        //cout<<rem<<" "<<i<<" "<<((i/t1)*(p1-s))<<"\n";
        int l1=(i/t1)*(p1-s), l2=(max(0ll,i+t1-t2)/t2)*(p2-s), l3=(i/t2)*(p2-s);
            //cout<<l1+l3<<"\n";

            if(l1+l3>=h-rem+1){
                //cout<<dp[rem-1]<<"\n";
                ans=min(ans,dp[rem-1]+i);
            }
            if(1&&(i+t1>=t2)){
                dp[min(h,rem-1+l1+l2+p1+p2-s)]=min(dp[min(h,rem-1+l1+l2+p1+p2-s)],dp[rem-1]+i+t1);
            }

        swap(t1,t2);
        swap(p1,p2);

        for(i=0;(i/t1)*(p1-s)<=(h-rem+1);i+=t1){
            int l1=(i/t1)*(p1-s), l2=(max(0ll,i+t1-t2)/t2)*(p2-s), l3=(i/t2)*(p2-s);
            //cout<<l1+l2<<"\n";

            if(l1+l3>=h-rem+1){
                //cout<<dp[rem-1]<<"\n";
                ans=min(ans,dp[rem-1]+i);
            }
            if(1&&(i+t1>=t2)){
                dp[min(h,rem-1+l1+l2+p1+p2-s)]=min(dp[min(h,rem-1+l1+l2+p1+p2-s)],dp[rem-1]+i+t1);
            }
        }
        l1=(i/t1)*(p1-s), l2=(max(0ll,i+t1-t2)/t2)*(p2-s), l3=(i/t2)*(p2-s);
            //cout<<l1+l2<<"\n";

            if(l1+l3>=h-rem+1){
                //cout<<dp[rem-1]<<"\n";
                ans=min(ans,dp[rem-1]+i);
            }
            if(1&&(i+t1>=t2)){
                dp[min(h,rem-1+l1+l2+p1+p2-s)]=min(dp[min(h,rem-1+l1+l2+p1+p2-s)],dp[rem-1]+i+t1);
            }

        swap(t1,t2);
        swap(p1,p2);
    }

    cout<<min(ans,dp[h])<<"\n";
    //memset(a,0,sizeof(a));
    //cout<<fixed<<setprecision(10)<<ans<<"\n";

}

signed main()
{   /*
   #ifndef ONLINE_JUDGE
   freopen("inputhsr.txt", "r", stdin);
   freopen("outputhsr.txt", "w", stdout);
   #endif
   */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    /*
    fac[0]=1;
    for(i=1;i<N;i++){
        fac[i]=(i*fac[i-1])%mod;
    }
    */

    int t=1;
    int T=1;
    //cin>>T;
    for(t=1;t<=T;t++){

        //google(t);
        solve();

    }

    return 0;
}

#include<bits/stdc++.h>
#define NN 5100

using namespace std;
using INT=long long;

INT dp[NN], t[2];
int p[2];
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	for(int i = 0; i < 2; i ++) cin >> p[i] >> t[i];
	int h, s; cin >> h >> s;
	for(int i = 1; i <= h; i ++) {
		dp[i] = 1e18;
		for(int j = 1; j <= h; j ++) {
			for(int k = 0; k < 2; k ++) {
				INT T = t[k] * j;
				if(T < t[k^1]) continue;
				INT tmp = min(5000ll, (T - t[k^1]) / t[k^1]) * (p[k^1] - s);
				tmp += (j - 1) * (p[k] - s);
				tmp += (p[1] + p[0] - s);
				dp[i] = min(dp[i], T + dp[max(0ll, i - tmp)]);
			}
		}
		INT st = 0, ed = 1LL * 5001 * min(t[1], t[0]);
		while(st + 1 < ed) {
			INT md = (st + ed) >> 1;
			INT tmp = 0;
			for(int k = 0; k < 2; k ++) {
				tmp += (md / t[k]) * (p[k] - s);
			}
			if(tmp >= i) ed = md;
			else st = md;
		}
		dp[i] = min(dp[i], ed);
	}
	cout << dp[h] << endl;

	return 0;
}

#include <algorithm>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <utility>
#include <limits.h>
#include <climits>
#include <numeric>
#include <map>
#include <unordered_map>
#include <cfloat>
#include <queue>
#define ll long long int
#define DEBUG false
using namespace std;

void debug(string s) {
    if (DEBUG) cout << s << endl;
}

void debug(int s) {
    if (DEBUG) cout << s << endl;
}

void debug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}

//flat debug of vector of vectors
void fdebug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j];
            if (j != v[i].size() - 1) {
                cout << " ";
            }
        }
        cout << "; ";
    }
    cout << endl;
}

void debug(vector<ll> & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        cout << v[i] << " ";
    }
    cout << endl;
}

ll MX = 1.e16;

class Solution {
    ll p1, t1, p2, t2, h, s;
public:
    void init() {
        cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

        if (DEBUG) {
            MX = 1.e16;
        }
    }

    ll solve() {
        init();
        if (t1 == t2) {
            ll res = (h + p1 + p2 - s - 1) / (p1 + p2 - s) * t1;
            return res;
        }

        // minimum time to cut at least i energy and shoot two guns at last
        vector<ll> dp(h + 1, MX);
        dp[0] = 0;
        ll first(0), second(0);
        ll e(0), t(0); // energy and time killed so far
        while (true) {
            // this happens only first time
            if ((first == 0) and (second == 0)) {
                if (t1 < t2) {
                    first = 0;
                    second = t1;
                    e += p1 - s;
                    t = t1;
                } else {
                    second = 0;
                    first = t2;
                    e += p2 - s;
                    t = t2;
                }
            } else { // either first == 0 or second == 0
                // shoot first
                if (first == 0) {
                    // wait
                    ll ew = e + p2;
                    ll tw = t + t2 - second;
                    if (ew <= h) {
                        dp[ew] = min(dp[ew], tw);
                    } else {
                        dp[h] = min(dp[h], tw);
                    }
                }
                if (second == 0) {
                    // wait
                    ll ew = e + p1;
                    ll tw = t + t1 - first;
                    if (ew <= h) {
                        dp[ew] = min(dp[ew], tw);
                    } else {
                        dp[h] = min(dp[h], tw);
                    }
                }
                // shoot the cheapest
                if (t1 - first == t2 - second) {
                    e += p1 + p2 - s;
                    t += t1 - first;
                    first = 0;
                    second = 0;
                } else if (t1 - first < t2 - second) {
                    e += p1 - s;
                    t += t1 - first;
                    second += t1 - first;
                    first = 0;
                } else {
                    e += p2 - s;
                    t += t2 - second;
                    first += t2 - second;
                    second = 0;
                }
            }
            if (DEBUG) {
                cout << e << " " << t << " " << first << " " << second << endl;
            }
            if (e >= h) {
                dp[h] = min(dp[h], t);
                break;
            }
            dp[e] = min(dp[e], t);
            if ((first == 0) and (second == 0)) {
                break;
            }
        }

        debug(dp);

        debug(dp);

        // update
        for (ll i = 1; i <= h; ++i) {
            for (ll j = 1; j <= h; ++j) {
                dp[min(i + j, h)] = min(dp[min(i + j, h)], dp[i] + dp[j]);
            }
        }
        /* for (int i = 1; i <= h; ++i) {
            for (int j = 1; 2 * j <= i; ++j) {
                dp[i] = min(dp[i], dp[j] + dp[i - j]);
            }
        }*/

        //
        /*for (int i = h - 1; i >= 0; --i) {
            dp[i] = min(dp[i], dp[i + 1]);
        }*/

        debug(dp);

        // update general
        /*first = 0;
        second = 0;
        e = 0;
        t = 0;
        ll res(dp[h]);
        while (e < h) {
            // shoot first
            if (t1 - first < t2 - second) {
                e += p1 - s;
                t += t1 - first;
                second += t1 - first;
                first = 0;
                if (e >= h) {
                    res = min(res, t);
                } else {
                    res = min(res, t + dp[h - e]);
                }
            } else if (t2 - second < t1 - first) {
                e += p2 - s;
                t += t2 - second;
                first += t2 - second;
                second = 0;
                if (e >= h) {
                    res = min(res, t);
                } else {
                    res = min(res, t + dp[h - e]);
                }
            } else {
                break;
            }
            if (DEBUG) {
                cout << " " << e << " " << t << " " << dp[h - e] << " " << res << endl;
            }
        }*/

        return dp[h];

        /*priority_queue<vector<ll>, vector<vector<ll>>, greater<vector<ll>>> q;
        //vector<ll> d;  // distance
        vector<ll> v = {0, 0, 0, 0};  // distance, t1, t2, energy reduction
        //d.push_back(0);
        q.push(v);

        while (!q.empty()) {
            vector<ll> v = q.top();
            q.pop();
            if (v[3] >= h) return v[0];
            // else
            if ((v[1] == t1) and (v[2] == t2)) {
                // shoot both if can
                ll e = v[3] + p1 + p2 - s;
                vector<ll> w = {v[0], 0, 0, e};
                q.push(w);
            } else if (v[1] == t1) {
                // shoot first
                ll e = v[3] + (p1 - s);
                vector<ll> w = {v[0], 0, v[2], e};
                q.push(w);
                // or wait
                w = {v[0] + t2 - v[2], t1, t2, v[3]};
                q.push(w);
            } else if (v[2] == t2) {
                // shoot second
                ll e = v[3] + (p2 - s);
                vector<ll> w = {v[0], v[1], 0, e};
                q.push(w);
                // or wait
                w = {v[0] + t1 - v[1], t1, t2, v[3]};
                q.push(w);
            } else {
                if (t1 - v[1] < t2 - v[2]) {
                    vector<ll> w = {v[0] + t1 - v[1], t1, v[2] + t1 - v[1], v[3]};
                    q.push(w);
                } else {
                    vector<ll> w = {v[0] + t2 - v[2], v[1] + t2 - v[2], t2, v[3]};
                    q.push(w);
                }
            }
        } */

        //return 0;
    }

};

int main()
{
    int n = 1;
    //cin >> n;
    Solution sol;
    for(int i = 1; i != n + 1; ++i) {
        cout << fixed << setprecision(0) << sol.solve() << "\n";
    }

    return 0;
}

#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <set>
#include <stack>
#include <array>
#include <bitset>
#include <chrono>
#define int ll
typedef long long ll;
using namespace std;
signed main() {
    int p1;
    ll t1;
    int p2;
    ll t2;
    cin >> p1 >>  t1 >> p2 >> t2;
    int h, s;
    cin >> h >> s;
    vector<pair<int, ll>> acts;
    {
        int ch = h;
        ll b1 = 0, b2 = 0;
        ll mm = 0;
        while (ch > 0) {
            {
                acts.emplace_back(h - max(ch - p1 - p2 + s, 0LL),
                                  max(b1 + t1, b2 + t2));
            }
            if (b1 + t1 == b2 + t2) {
                mm = max(b1 + t1, b2 + t2);
                ch -= p1 + p2 - s;
                b1 = b2 = mm;
            } else {
                if (b1 + t1 < b2 + t2) {
                    mm = b1 + t1;
                    ch -= p1 - s;
                    b1 = mm;
                } else {
                    mm = b2 + t2;
                    ch -= p2 - s;
                    b2 = mm;
                }
            }
        }
    }
    vector<ll> dp(2 * h + 1, t1 * 5000);
    dp[0] = 0;
    for (auto [dt, tm] : acts) {
        for (int i = 0; i + dt <= 2 * h; ++i) {
            dp[i + dt] = min(dp[i + dt], dp[i] + tm);
        }
    }
    ll ans = t1 * 5000;
    for (int j = 0; j <= 2 * h; ++j) {
        int ch = h - j;
        ll b1 = 0, b2 = 0;
        ll mm = 0;
        while (ch > 0) {
            if (b1 + t1 == b2 + t2) {
                mm = max(b1 + t1, b2 + t2);
                ch -= p1 + p2 - s;
                b1 = b2 = mm;
            } else {
                if (b1 + t1 < b2 + t2) {
                    mm = b1 + t1;
                    ch -= p1 - s;
                    b1 = mm;
                } else {
                    mm = b2 + t2;
                    ch -= p2 - s;
                    b2 = mm;
                }
            }
        }
        ans = min(ans, mm + dp[j]);
    }
    cout << ans;
    return 0;
}

#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using TP = tuple<int, int, int>;
#define all(x) x.begin(),x.end()
#define mst(x,v) memset(x,v,sizeof(x))
#define mul(x,y) (1ll*(x)*(y)%mod)
#define mk make_pair
//#define int LL
//#define double LD
//#define lc p*2
//#define rc p*2+1
#define endl '\n'
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#pragma warning(disable : 4996)
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
const double eps = 1e-8;
const double pi = acos(-1);
const LL MOD = 1000000007;
const LL mod = 998244353;
const int maxn = 10010;

LL P[3], T[3], H, S, f[maxn], g[maxn], N, D[4];

void solve()
{
	D[1] = P[1] - S, D[2] = P[2] - S, D[3] = P[1] + P[2] - S;
	mst(g, INF), mst(f, INF), g[0] = f[0] = 0;
	LL N = H + max(P[1], P[2]), ans = min((D[1] + H - 1) / D[1] * T[1], (D[2] + H - 1) / D[2] * T[2]);
	for (int i = 1; i <= N; i++)
	{
		for (int j = 0; j * D[1] + D[3] <= N; j++)
			f[i] = min(f[i], max(T[1] * (j + 1), T[2] * (max(0LL, (i - j * D[1] - D[3] + D[2] - 1)) / D[2] + 1)));
		for (int j = 0; j < i; j++)
			g[i] = min(g[i], g[j] + f[i - j]);
		if (i >= H)
			ans = min(g[i], ans);
	}
	cout << ans << endl;
}

int main()
{
	IOS;
	for (int i = 1; i <= 2; i++)
		cin >> P[i] >> T[i];
	cin >> H >> S;
	solve();
	return 0;
}

#include<bits/stdc++.h>
#define INT long long
using namespace std;
const int NN = 5100;
INT dp[NN], t[2];
int p[2];
int main() {
	for(int i = 0; i < 2; i ++) cin >> p[i] >> t[i];
	int h, s;
	cin >> h >> s;
	for(int i = 1; i <= h; i ++) {
		dp[i] = 1e18;
		for(int j = 1; j <= h; j ++) {
			for(int k = 0; k < 2; k ++) {
				INT T = t[k] * j;
				if(T < t[k ^ 1]) continue;
				INT tmp = min(5000ll, (T - t[k^1]) / t[k^1]) * (p[k^1] - s);
				tmp += (j - 1) * (p[k] - s);
				tmp += (p[1] + p[0] - s);
				dp[i] = min(dp[i], T + dp[max(0ll, i - tmp)]);
			}
		}
		INT st = 0, ed = 1LL * 5001 * min(t[1], t[0]);
		while(st + 1 < ed) {
			INT md = (st + ed) >> 1;
			INT tmp = 0;
			for(int k = 0; k < 2; k ++) {
				tmp += (md / t[k]) * (p[k] - s);
			}
			if(tmp >= i) ed = md;
			else st = md;
		}
		dp[i] = min(dp[i], ed);
	}
	cout << dp[h] << endl;
}

#include <bits/stdc++.h>
#define nn printf("NO\n")
#define yy printf("YES\n")
#define nnn printf("No\n")
#define yyy printf("Yes\n")
using namespace std;
using LL=long long;
typedef pair<int,int> PII;
const int N=500001;
const LL mod=1000000007;
//const LL mod=998244353;
vector<int> e[N];
int f[N],x,y,z;
int n,m,k;
void bcjInit() {for (int i=1;i<=n;++i) f[i]=i;}
int find(int x) {return f[x]==x?x:f[x]=find(f[x]);}
LL gcd(LL x,LL y) {return y==0?x:gcd(y,x%y);}
long long t1,t2,dp[5001],t,p1,p2,s,h,p;
int solve()
{
	cin>>p1>>t1;
	cin>>p2>>t2;
	cin>>h>>s;
	dp[0]=0;
	for (int i=1;i<=h;++i) dp[i]=1ll<<60;
	for (int i=1;;++i)
	{
		t=i*t1;
		p=i*p1-i*s+t/t2*p2-t/t2*s;
		if (t/t2) p+=s;
		for (int j=min(p,h);dp[j]>t;--j) dp[j]=t;
		if (p>h) break;
	}
	for (int i=1;;++i)
	{
		t=i*t2;
		p=i*p2-i*s+t/t1*p1-t/t1*s;
		if (t/t1) p+=s;
		for (int j=min(p,h);dp[j]>t;--j) dp[j]=t;
		if (p>h) break;
	}
	for (int i=1;i<=h;++i)
		for (int k=1;k<=i-k;++k) dp[i]=min(dp[i],dp[k]+dp[i-k]);

	printf("%lld\n",dp[h]);
}
int main()
{
	int T=1;
//	for (scanf("%d",&T);T--;)
//      if (solve()) printf("YES\n");
//      else printf("NO\n");

//	for (scanf("%d",&T);T--;) solve();

	solve();
	return 0;
}

// LUOGU_RID: 92642787
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
#define FOR(i,u) for(int i=head[u];i;i=e[i].next)
#define endl "\n"
int read()
{
	int x;
	scanf("%lld",&x);
	return x;
}
using namespace std;
const int N=1e5+5;
int p1,p2,t1,t2,h,s;
const int INF=1e16+5;
int dp[N],dis[N];//Ôì³ÉiµãÉËº¦ÇÒ×îºóÒ»¸öÊä³öÊÇË«ÅÚÆëÉä
int cost(int time1,int time2,int w)
{
	if(w<0) return max(time1,time2);
	if(time1==t1&&time2==t2&&dis[w]) return dis[w];
	int l=max(time1,time2),r=INF,ans=INF;
	while(l<=r)
	{
		int mid=l+r>>1;
		int d1=(mid-time1)/t1*(p1-s),d2=(mid-time2)/t2*(p2-s);
		if((d1)+(d2)>=w)
		{
			ans=mid;
			r=mid-1;
		}
		else
		{
			l=mid+1;
		}
	}
	return dis[w]=ans;
}
signed main()
{
	p1=read(),t1=read();
	p2=read(),t2=read();
	h=read(),s=read();
	rep(i,1,max(p1,max(p2,h))) dp[i]=INF;
	dp[0]=0;
	rep(i,1,max(p1,max(p2,h)))
	{
		rep(j,0,i-1)
		{
			dp[i]=min(dp[i],dp[j]+cost(t1,t2,(i-j-(p1+p2-s))));
		}
	}
	int ans=INF;
	rep(i,0,max(p1,max(p2,h)))
	{
		if(i<=h)ans=min(ans,dp[i]+cost(0,0,(h-i)));
		else ans=min(ans,dp[i]);
	}
	cout<<ans<<endl;
	return 0;
}

#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define ms(x, y) memset(x, y, sizeof(x))
#define Mod 322122547191331
typedef long long ll;

using namespace std;
ll dam[5555];
int main() {
    ios::sync_with_stdio(0);
    ll p1, t1, p2, t2, h, s;
    vector<ll> dp(5555,LLONG_MAX>>4);
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
    if (t1 > t2) {
        swap(t1, t2);
        swap(p1, p2);
    }

    dp[0]=0;
    for(int i=1;i<=h;i++){
        int d=0;
        int last=i-1;
        int cnt2=0;
        int cnt1=1;
        while(d<=i){
            cnt2++;
            while(cnt1*t1<(cnt2+1)*t2){
                d=cnt1*(p1-s)+cnt2*(p2-s)+s;
                ll t=max(cnt1*t1,cnt2*t2);
                // if(d<=i)dp[i]=min(dp[i],dp[i-d]+t);
                for(int j=max(0,i-d);j<=last;j++)dp[i]=min(dp[i],dp[j]+t);
                last=i-d;
                if(last<0)break;

                cnt1++;
            }
        }
    }
    // cout<<dp[8]<<endl;
    ll ans=dp[h];
    ll c=1;
    while(1){
        ans=min(ans,dp[max(0ll,h-(p1-s)*c)]+t1*c);
        if(h-(p1-s)*c<=0)break;
        // break;
        c++;
    }
    cout<<ans<<endl;
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
int T;
ll p1,t1;
ll p2,t2;
ll h,s;
ll a[N],b[N],cnt;
ll dp[N];//造成i 点damage的 最少时间
void solve(){
	scanf("%lld%lld",&p1,&t1);
	scanf("%lld%lld",&p2,&t2);
	scanf("%lld%lld",&h,&s);
	ll ans=1e18;
	for(int i=1;i<=h;++i){
		if(i*t1<t2)continue;
		a[++cnt]=(i-1)*(p1-s)+(i*t1/t2-1)*(p2-s)+(p1+p2-s);
		b[cnt]=i*t1;
	}
	for(int i=1;i<=h;++i){
		if(i*t2<t1)continue;
		a[++cnt]=(i-1)*(p2-s)+(i*t2/t1-1)*(p1-s)+(p1+p2-s);
		b[cnt]=i*t2;
	}

	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=cnt;++i)
		for(int j=0;j<h;++j)
			if(dp[j]<1e18)dp[min(h,j+a[i])]=min(dp[min(h,j+a[i])],dp[j]+b[i]);

	for(int j=0;j<h;++j)
		if(dp[j]<1e18)dp[min(h,j+(p1-s))]=min(dp[min(h,j+(p1-s))],dp[j]+t1);
	for(int j=0;j<h;++j)
		if(dp[j]<1e18)dp[min(h,j+(p2-s))]=min(dp[min(h,j+(p2-s))],dp[j]+t2);
	ans=min(ans,dp[h]);
	printf("%lld\n",ans);
}
int main(){
	solve();
	return 0;
}

#include<bits/stdc++.h>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define bit(s, i) (s & (1<<i))

using namespace std;

const int N = 5e3 + 5;
const int M = 1;
const int K = 1;
const int mod = 1e9+7;
const int inf = 2e9;
const long long Inf = 2e18;

typedef long long ll;
typedef pair < int, int > ii;

long long t[2], dp[N], h, s, p[2];

int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // freopen("trash.inp","r",stdin);
    // freopen("trash.out","w",stdout);

    for(int i=0;i<2;++i) cin >> p[i] >> t[i];
    cin >> h >> s;

    memset(dp, 0x3f, sizeof dp);
    dp[0] = 0;
    long long res = Inf;
    for(long long i=0;i<h;++i)
    for(long long k=0;k<2;++k) {
        for(int j=1;j<=h-i;++j) {
            long long e = (1ll * t[k] * j) / t[1 - k];
            long long nw = min(h, i + 1ll * (p[k] - s) * j + 1ll * (p[1 - k] - s) * e);
            if(nw == h) res = min(res,  dp[i] + t[k] * j);
            if(e) {
                nw = min(h,
                i + 1ll * (p[k] - s) * (j - 1) + 1ll * (p[1 - k] - s) * (e - 1) + p[0] + p[1] - s);
                dp[nw] = min(dp[nw], dp[i] + t[k] * j);
            }
            res = min(res, dp[h]);
        }
    }
    cout << res;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int p1,p2,h,s;
ll t1,t2;

ll dp[5005];
int main()
{
	scanf("%d%lld%d%lld%d%d",&p1,&t1,&p2,&t2,&h,&s);

	dp[0]=0;
	for(int i=1;i<=h;++i)
	{
		dp[i]=min(dp[max(i-(p1-s),0)]+t1,dp[max(0,i-(p2-s))]+t2);
		for(ll j=0;j<i;++j)//1自己动j次，再合击
		{
			ll deltime=(j+1)*t1;
			if(deltime<t2)continue;

			ll ci2=deltime/t2-1;//2单独动
			assert(ci2>=0);
			ll dmg=ci2*(p2-s)+j*(p1-s)+(p1+p2-s);
			dp[i]=min(dp[i],dp[max(0LL,i-dmg)]+deltime);
		}
		for(ll j=0;j<i;++j)//2自己动j次，再合击
		{
			ll deltime=(j+1)*t2;
			if(deltime<t1)continue;

			ll ci1=deltime/t1-1;//1单独动
			assert(ci1>=0);
			ll dmg=ci1*(p1-s)+j*(p2-s)+(p1+p2-s);
			dp[i]=min(dp[i],dp[max(0LL,i-dmg)]+deltime);
		}
	}
	printf("%lld\n",dp[h]);
	return 0;
}

#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
// #include<ext/rope>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/priority_queue.hpp>
// #include<ext/pb_ds/hash_policy.hpp>
#define IOS std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin.exceptions(ios::badbit | ios::failbit)
#define endl '\n'
#define lowbit(x) ((x)&(-x))
#define ls (now<<1)
#define rs (now<<1|1)
// #define SPLAY
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// typedef __int128 lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#ifdef Iheadx
char __st;
clock_t C1,C2;
#endif
ll qpow(ll a,ll b,ll mod){
    a%=mod;
    ll res=1;
    while(b){
        if(b%2) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res%mod;
}
void read(){}
template<typename READ1,typename... READ2>
inline void read(READ1 &x,READ2 &... OTH){
    x=0;int f=1;char c=getchar();
    while(!isdigit(c)){
        if(c=='-') f=-1;
        c=getchar();
    }
    while(isdigit(c)){
        x=x*10+c-'0';
        c=getchar();
    }
    x*=f;
    read(OTH...);
}
template<typename PUT>
void print(PUT x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
const int mod=1e9+7;
const int MOD=998244353;
const double PI=acos(-1);
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-10;
int dx[4]={1,0,0,-1};
int dy[4]={0,-1,1,0};
const int M=2e5+20;
const int N=2e6+20;
/*-------------------------------------*/
// #define Tree tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
// using namespace __gnu_cxx;
// using namespace __gnu_pbds;

ll dp[5010];

/*-------------------------------------*/
#ifdef Iheadx
char __end;
#endif
int main(){
#ifdef Iheadx
    int SIZE=128<<20;//128MB栈空间
    //32位Windows
    //__asm__("movl %0, %%esp\n"::"r"((char*)malloc(size)+size));

    //Linux/64位Windows
    __asm__("movq %0, %%rsp\n"::"r"((char*)malloc(SIZE)+SIZE));

    C1=clock();
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    cerr<<"\nMemory : "<<fixed<<setprecision(5)<<abs(&__end-&__st)*1.0/1048576<<" MB"<<endl;
#endif
/*-------------------------------------*/
    IOS;

    ll p1,t1,p2,t2,h,s;
    cin>>p1>>t1>>p2>>t2>>h>>s;
    memset(dp,0x3f,sizeof dp);
    dp[0]=0;
    for(int i=1;i<=h;i++){
        dp[i]=min(dp[max(0ll,i-p1+s)]+t1,dp[max(0ll,i-p2+s)]+t2);
        for(int j=1;j<=i;j++){
            if(t1*j>=t2){
                ll dam=(j-1)*(p1-s)+(t1*j-t2)/t2*(p2-s)+p1+p2-s;
                dp[i]=min(dp[i],dp[max(0ll,i-dam)]+t1*j);
            }
            if(t2*j>=t1){
                ll dam=(j-1)*(p2-s)+(t2*j-t1)/t1*(p1-s)+p1+p2-s;
                dp[i]=min(dp[i],dp[max(0ll,i-dam)]+j*t2);
            }
        }
    }
    cout<<dp[h];

/*-------------------------------------*/
end:
#ifdef Iheadx
        C2=(clock()-C1);
        cerr<<"\nTime Used: "<<C2<<" ms\n";
        exit(0);
#endif
    return 0;
}

#include<bits/stdc++.h>
#define rg register
#define il inline
#define cn const
#define gc getchar()
#define fp(i,a,b) for(rg int i=(a),ed=(b);i<=ed;++i)
#define fb(i,a,b) for(rg int i=(a),ed=(b);i>=ed;--i)
#define go(u) for(rg int i=head[u];i;i=e[i].nxt)
using namespace std;
typedef cn int cint;
typedef long long LL;
il int rd(){
	rg int x(0), f(1); rg char c(gc);
	while(c<'0'||'9'<c){if(c=='-')f=0;c=gc;}
	while('0'<=c&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=gc;
	return f ? x : -x;
}
cint maxn = 5010;
int p1, p2, h, s;
LL t1, t2, f[maxn];
int main(){
//	freopen("a.in", "r", stdin);
//	freopen("a.out", "w", stdout);
	scanf("%d %lld", &p1, &t1);
	scanf("%d %lld", &p2, &t2);
	scanf("%d %d", &h, &s);
	memset(f, 0x3f, sizeof f), f[0] = 0;
	fp(i, 0, h){
		f[min(h, i+p1-s)] = min(f[min(h, i+p1-s)], f[i]+t1);
		f[min(h, i+p2-s)] = min(f[min(h, i+p2-s)], f[i]+t2);
		fp(j, 1, h){
			if(j*t1 >= t2){
				LL dam = 1ll*(j-1)*(p1-s) + (j*t1-t2)/t2*(p2-s) + p1+p2-s;
				f[min((LL)h, i+dam)] = min(f[min((LL)h, i+dam)], f[i]+j*t1);
			}
			if(j*t2 >= t1){
				LL dam = 1ll*(j-1)*(p2-s) + (j*t2-t1)/t1*(p1-s) + p1+p2-s;
				f[min((LL)h, i+dam)] = min(f[min((LL)h, i+dam)], f[i]+j*t2);
			}
		}
	}
	printf("%lld\n", f[h]);
//	fp(i, 0, h)printf("%lld ", f[i]);
	return 0;
}
/*
3 19
4 29
11 2
*/

#include<iostream>
#include<cstring>
#include<cstdio>
#define int long long

using namespace std;

const int N = 5010;
int f[N][N];

signed main()
{
	int p1 , t1;
	scanf("%lld %lld",&p1,&t1);
	int p2 , t2;
	scanf("%lld %lld",&p2,&t2);
	if(t2<t1)
	{
		swap(p1,p2);
		swap(t1,t2);
	}
	int h , s;
	int ans = 1e18;
	scanf("%lld %lld",&h,&s);
	memset(f,0x3f,sizeof f);
	f[0][0] = 0;
	for(int i = 0 ; i <= h ; i++)
	{
		for(int j = 0 ; j <= 5000 ; j++)
		{
			int left = j*t1%t2;
			left = t2 - left;
			if(left<t1)
			{
				if(i+p2-s>=h)
				{
					ans = min(ans,f[i][j]+t2);
				}
				else
				{
					if(i+p1+p2-s>=h)
					{
						ans = min(ans,f[i][j]+t1);
					}
					else
					{
						f[i+p1+p2-2*s][j+1] = min(f[i+p1+p2-2*s][j+1],f[i][j]+t1);
					}
				}
			}
			if(left>t1)
			{
				if(i+p1-s>=h)
				{
					ans = min(ans,f[i][j]+t1);
				}
				else
				{
					f[i+p1-s][j+1] = min(f[i+p1-s][j+1],f[i][j]+t1);
				}
			}
	 		if(i+p1+p2-s>=h)
	 		{
	 			ans = min(ans,f[i][j]+max(left,t1));
			}
			else
				f[i+p1+p2-s][0] = min(f[i+p1+p2-s][0],f[i][j]+max(left,t1));
		}
	}
	cout<<ans<<endl;
	return 0;
}

#include<iostream>
#include<vector>
using namespace std;

const int N = 5e3 + 5;
typedef long long ll;

ll p1, t1, p2, t2, h, s;

int main() {
	cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
	if (t1 > t2)swap(t1, t2), swap(p1, p2);
	vector<vector<ll>> dp(5005,vector<ll>(5005, 1e16));
	dp[h][0] = 0;
	ll ans = 1e16;

	for (int i = h; i >= 0; i--)
		for (int j = 0; j <= 5000; j++) {
			ll wtime = (j * t1) % t2;
			wtime = t2 - wtime;
			//等待t2发射
			if (wtime < t1 && i <= p2 - s)ans = min(ans, dp[i][j] + wtime);
			//发射t1，但发射不了t2
			if (wtime > t1) {
				if (i <= p1 - s)ans = min(ans, dp[i][j] + t1);
				else dp[i - p1 + s][j + 1] = min(dp[i - p1 + s][j + 1], dp[i][j] + t1);
			}
			//发射t1时，且发射了t2
			if (wtime<t1 && i>p2 - s) {
				if (i <= p1 - s + p2 - s)ans = min(ans, dp[i][j] + t1);
				else dp[i - p1 + s - p2 + s][j + 1] = min(dp[i - p1 + s - p2 + s][j + 1], dp[i][j] + t1);
			}
			//同时发射
			if (i <= p1 + p2 - s)ans = min(ans, dp[i][j] + max(t1, wtime));
			else dp[i - p1 - p2 + s][0] = min(dp[i - p1 - p2 + s][0], dp[i][j] + max(wtime, t1));
		}
	cout << ans;
}

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

#define FOR(i,n) for(int i=0; i<n; i++)
#define FOR1(i,n) for(int i=1; i<=n; i++)

typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll, ll> pll;
#define xx first
#define yy second

typedef tuple<int, int, int> int3;
#define g0(x) get<0>(x)
#define g1(x) get<1>(x)
#define g2(x) get<2>(x)
#define g3(x) get<3>(x)
#define g4(x) get<4>(x)

ll gcd(const ll& a, const ll& b) {
    return (b == 0 ? a : gcd(b, a % b));
}
    const int DMAX = 5000;
    ll a[DMAX*2][DMAX+1];
    ll b[DMAX+1];
    int c[DMAX*2];

int main() {
#if !ONLINE_JUDGE && 1
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
#if ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
#endif

    //int d[DMAX];
    //unordered_map<int, int> mii;

    int set_count = 1;
    //cin >> set_count;
    for(int set_number=0; set_number<set_count; set_number++) {
        //memset(arr, 0, sizeof(int)*DMAX);
        ll p1, t1, p2, t2; cin >> p1 >> t1 >> p2 >> t2;
        if (t2 < t1) {
            swap(p1,p2);
            swap(t1,t2);
        }
        ll h, s; cin >> h >> s;
        if (t1 == t2) {
            cout << (h+p1+p2-s-1) / (p1+p2-s) * t1 << '\n';
            continue;
        }

        if (p1 == s) {
            cout << (h + p2 - 1) / p2 * t2 << '\n';
            continue;
        }

        ll gm = gcd(t1, t2);
        t1 /= gm; t2 /= gm;

        if (t1 == 1) {
            ll c2 = h / (t2 * (p1 - s) + p2);
            ll rem = h - c2 * (t2 * (p1 - s) + p2);
            ll c1 = 0;
            if (rem > 0) {
                c1 = (rem + (p1 - s) - 1) / (p1 - s);
                if (c1 > t2) {
                    c2++;
                    c1 = 0;
                }
            }
            cout << (c2*t2 + c1)*gm << '\n';
            continue;
        }

        ll c1 = 0, c2 = 0;
        int cp = 0;
        a[0][0] = 0; c[0] = b[0] = 0;
        int vc = 0;
        while ((c2 < t1) && (cp < DMAX)) {
            while(((c1+1) * t1 < (c2+1) * t2) && (cp < DMAX)) {
                c1++;
                int ncp = cp + (p1-s);
                ll nt = c1 * t1;
                while ((cp < ncp) && (cp < DMAX)) {
                    cp++;
                    a[0][cp] = b[cp] = nt;
                }
            }
            if ((c1+1) * t1 == (c2+1) * t2) {
                c1++; c2++;
                int ncp = cp + (p1+p2-s);
                ll nt = c1 * t1;
                while ((cp < ncp) && (cp < DMAX)) {
                    cp++;
                    a[0][cp] = b[cp] = nt;
                }
                break;
            }
            if (cp < DMAX) {
            vc++;
            int ncp = cp + p2;
            ll nt = (c2+1) * t2;
            a[vc][0] = 0; c[vc] = ncp;
            for(int i=1; (i<=ncp) && (i<=DMAX); i++) a[vc][i] = nt;
            for(int i=ncp+1; i<=DMAX; i++) a[vc][i] = 0;

            vc++;
            ncp = cp + (p1+p2-s);
            nt = (c1+1) * t1;
            a[vc][0] = 0; c[vc] = ncp;
            for(int i=1; (i<=ncp) && (i<=DMAX); i++) a[vc][i] = nt;
            for(int i=ncp+1; i<=DMAX; i++) a[vc][i] = 0;

            ncp = cp + (p2-s);
            nt = (c2+1) * t2;
            while ((cp < ncp) && (cp < DMAX)) {
                cp++;
                a[0][cp] = b[cp] = nt;
            }
            ncp = cp + (p1-s);
            nt = (c1+1) * t1;
            while ((cp < ncp) && (cp < DMAX)) {
                cp++;
                a[0][cp] = b[cp] = nt;
            }
            c1++; c2++;
            //cout << vc << '\n'; cout.flush();
            }
        }
        if (cp < DMAX) {
            c[0] = cp;
            for(int i=cp+1; i<=DMAX; i++) {
                a[0][i] = 0;
                b[i] = (ll)1e18;
            }
        }

        //FOR(i, 150) cout << i << ':' << b[i] << ' ';
        //cout << '\n';
        //FOR(j,10) {
        //    FOR(i,c[j]+1) cout << i << ':' << a[j][i] << ' ';
        //    cout << '\n';
        //}
        FOR1(d,DMAX) {
            FOR(j,vc+1) {
                if (a[j][d] == 0) a[j][d] = a[j][c[j]] + b[d-c[j]];
                b[d] = min(b[d], a[j][d]);
            }
        }
        //FOR(i, 150) cout << i << ':' << b[i] << ' ';
        //cout << '\n';
        cout << b[h] * gm << '\n';
        //cout << vc << '\n';
    }
    return 0;
}

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

#define FOR(i,n) for(int i=0; i<n; i++)
#define FOR1(i,n) for(int i=1; i<=n; i++)

typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll, ll> pll;
#define xx first
#define yy second

typedef tuple<int, int, int> int3;
#define g0(x) get<0>(x)
#define g1(x) get<1>(x)
#define g2(x) get<2>(x)
#define g3(x) get<3>(x)
#define g4(x) get<4>(x)

ll gcd(const ll& a, const ll& b) {
    return (b == 0 ? a : gcd(b, a % b));
}

int main() {
#if !ONLINE_JUDGE && 1
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
#if ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
#endif

    const int DMAX = 5000;
    ll a[DMAX+100][DMAX+1];
    ll b[DMAX+1];
    int c[DMAX*2];
    //int d[DMAX];
    //unordered_map<int, int> mii;

    int set_count = 1;
    //cin >> set_count;
    for(int set_number=0; set_number<set_count; set_number++) {
        //memset(arr, 0, sizeof(int)*DMAX);
        ll p1, t1, p2, t2; cin >> p1 >> t1 >> p2 >> t2;
        if (t2 < t1) {
            swap(p1,p2);
            swap(t1,t2);
        }
        ll h, s; cin >> h >> s;
        if (t1 == t2) {
            cout << (h+p1+p2-s-1) / (p1+p2-s) * t1 << '\n';
            continue;
        }

        if (p1 == s) {
            cout << (h + p2 - 1) / p2 * t2 << '\n';
            continue;
        }

        ll gm = gcd(t1, t2);
        t1 /= gm; t2 /= gm;

        if (t1 == 1) {
            ll c2 = h / (t2 * (p1 - s) + p2);
            ll rem = h - c2 * (t2 * (p1 - s) + p2);
            ll c1 = 0;
            if (rem > 0) {
                c1 = (rem + (p1 - s) - 1) / (p1 - s);
                if (c1 > t2) {
                    c2++;
                    c1 = 0;
                }
            }
            cout << (c2*t2 + c1)*gm << '\n';
            continue;
        }

        ll c1 = 0, c2 = 0;
        int cp = 0;
        a[0][0] = 0; c[0] = b[0] = 0;
        int vc = 0;
        while ((c2 < t1) && (cp < DMAX)) {
            while(((c1+1) * t1 < (c2+1) * t2) && (cp < DMAX)) {
                c1++;
                int ncp = cp + (p1-s);
                ll nt = c1 * t1;
                while ((cp < ncp) && (cp < DMAX)) {
                    cp++;
                    a[0][cp] = b[cp] = nt;
                }
            }
            if ((c1+1) * t1 == (c2+1) * t2) {
                c1++; c2++;
                int ncp = cp + (p1+p2-s);
                ll nt = c1 * t1;
                while ((cp < ncp) && (cp < DMAX)) {
                    cp++;
                    a[0][cp] = b[cp] = nt;
                }
                break;
            }
            if (cp < DMAX) {
            vc++;
            int ncp = cp + p2;
            ll nt = (c2+1) * t2;
            a[vc][0] = 0; c[vc] = ncp;
            for(int i=1; (i<=ncp) && (i<=DMAX); i++) a[vc][i] = nt;
            for(int i=ncp+1; i<=DMAX; i++) a[vc][i] = 0;

            vc++;
            ncp = cp + (p1+p2-s);
            nt = (c1+1) * t1;
            a[vc][0] = 0; c[vc] = ncp;
            for(int i=1; (i<=ncp) && (i<=DMAX); i++) a[vc][i] = nt;
            for(int i=ncp+1; i<=DMAX; i++) a[vc][i] = 0;

            ncp = cp + (p2-s);
            nt = (c2+1) * t2;
            while ((cp < ncp) && (cp < DMAX)) {
                cp++;
                a[0][cp] = b[cp] = nt;
            }
            ncp = cp + (p1-s);
            nt = (c1+1) * t1;
            while ((cp < ncp) && (cp < DMAX)) {
                cp++;
                a[0][cp] = b[cp] = nt;
            }
            c1++; c2++;
            //cout << vc << '\n'; cout.flush();
            }
        }
        if (cp < DMAX) {
            c[0] = cp;
            for(int i=cp+1; i<=DMAX; i++) {
                a[0][i] = 0;
                b[i] = (ll)1e18;
            }
        }

        //FOR(i, 150) cout << i << ':' << b[i] << ' ';
        //cout << '\n';
        //FOR(j,10) {
        //    FOR(i,c[j]+1) cout << i << ':' << a[j][i] << ' ';
        //    cout << '\n';
        //}
        FOR1(d,DMAX) {
            FOR(j,vc+1) {
                if (a[j][d] == 0) a[j][d] = a[j][c[j]] + b[d-c[j]];
                b[d] = min(b[d], a[j][d]);
            }
        }
        //FOR(i, 150) cout << i << ':' << b[i] << ' ';
        //cout << '\n';
        cout << b[h] * gm << '\n';
        //cout << vc << '\n';
    }
    return 0;
}

// Created by Saber777
#include <bits/stdc++.h>
using namespace std;
// #define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define LL long long
#define db double
#define ld long double
#define db1(x) cout<<#x<<"="<<(x)<<" "
#define db2(x) cout<<#x<<"="<<(x)<<"\n"
#define endl '\n'
#define int long long
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
const int maxn = 2e5 + 10;
const int maxm = 2e5 + 10;
const int N = 1e3 + 10;
const int P = 1e9 + 7;    //998244353
const int INF = 0x3f3f3f3f;
const double EPS=1e-6;
LL t1, t2;
int h, s, p1, p2;
LL dp[5050]; //造成i点伤害所需的最短时间
void solve() {
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
    for(int i = 0; i <= h; i++) {
    	dp[i] = 1e18;
    }
    dp[0] = 0;
    for(int i = 0; i < h; i++) {
    	chmin(dp[min(h, i + p1 - s)], dp[i] + t1);
    	chmin(dp[min(h, i + p2 - s)], dp[i] + t2);
    	for(int j = 1; j <= h; j++) { //枚举在第j次操作时同时操作
    		if(j * t1 - t2 >= 0) {
    			int cnt_2 = 1LL * (j * t1 - t2) / t2; // (j - 1) 次 t1 过程中 t2 的次数
	    		chmin(dp[min(h, i + cnt_2 * (p2 - s) + (j - 1) * (p1 - s) + p1 + p2 - s)], dp[i] + j * t1);
    		}
    		if(j * t2 - t1 >= 0) {
    			int cnt_1 = 1LL * (j * t2 - t1) / t1; // (j - 1) 次 t2 过程中 t1 的次数
	    		chmin(dp[min(h, i + cnt_1 * (p1 - s) + (j - 1) * (p2 - s) + p1 + p2 - s)], dp[i] + j * t2);
    		}
    	}
    }
    cout << dp[h] << endl;
}
signed main() {
	// cout.flags(ios::fixed); cout.precision(8);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    // freopen("1.in","r",stdin);
    // freopen("1.out","w",stdout);
   	// int T; scanf("%d", &T); while(T--)
    // int T; cin >> T; while(T--)
       solve();
    return 0;
}

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)

using namespace std;

const long long INF64 = 1e18;

int main() {
	vector<int> ps(2);
	vector<long long> ts(2);
	int h, s;
	forn(i, 2) scanf("%d%lld", &ps[i], &ts[i]);
	scanf("%d%d", &h, &s);
	long long ans = INF64;
	vector<long long> dp(h + 1, INF64);
	dp[0] = 0;
	forn(i, h) for (int j = 1; j <= h - i; ++j) forn(k, 2){
		int ni = min((long long)h, i + j * (ps[k] - s) + j * ts[k] / ts[k ^ 1] * (ps[k ^ 1] - s));
		if (ni == h)
			ans = min(ans, dp[i] + j * ts[k]);
		if (j * ts[k] >= ts[k ^ 1]){
			ni = min((long long)h, i + (j - 1) * (ps[k] - s) + (j * ts[k] / ts[k ^ 1] - 1) * (ps[k ^ 1] - s) + (ps[0] + ps[1] - s));
			dp[ni] = min(dp[ni], dp[i] + j * ts[k]);
		}
	}
	ans = min(ans, dp[h]);
	printf("%lld\n", ans);
}

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

template<typename hd, typename tl> void chkmin(hd& a, tl b) { if(b < a) a = b; }
template<typename hd, typename tl> void chkmax(hd& a, tl b) { if(a < b) a = b; }
#define pb push_back
#define pob pop_back
#define endl '\n'
using LL = long long;
using PI = pair<int, int>;
using VI = vector<int>;
const int MX = 10005;
int a[MX];
#define inf 1e18
LL val[MX], dp[MX];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
#endif

	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	LL p1, t1;
	LL p2, t2;
	LL h, s;
	cin >> p1 >> t1;
	cin >> p2 >> t2;
	cin >> h >> s;
	for (int i = 0; i < MX; i ++) val[i] = inf;
	for (int i = 0; i < MX; i ++)
		for (int j = 0; j < MX; j ++) {
			int x = i * (p1 - s) + j * (p2 - s);
			if (x < MX) val[x] = min (val[x], max(t1 * i, t2 * j));
		}
	for (int i = 1; i < MX; i ++) {
		LL x, j = t1 * i / t2;
		if (j) x = i * (p1 - s) + j * (p2 - s) + s;
		if (x < MX) val[x] = min(val[x], t1 * i);
	}
	for (int i = 1; i < MX; i ++) {
		LL x, j = t2 * i / t1;
		if (j) x = i * (p2 - s) + j * (p1 - s) + s;
		if (x < MX) val[x] = min(val[x], t2 * i);
	}
	for (int i = 0; i < MX; i ++) dp[i] = inf;
	dp[0] = 0;
	for (int i = 0; i < MX; i ++) {
		for (int j = i; j < MX; j ++) {
			dp[j] = min (dp[j], dp[j - i] + val[i]);
		}
	}
	LL rlt = inf;
	for (int i = h; i < MX; i ++) rlt = min (rlt, dp[i]);
	cout << rlt << endl;
	return 0;
}

// LUOGU_RID: 93148278
#include<bits/stdc++.h>
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int f = 0; char ch = getchar();
	while(!isdigit(ch))
		f |= ch == '-', ch = getchar();
	while(isdigit(ch))
		x = x * 10 + ch - 48, ch = getchar();
	x = f ? -x : x; return;
}
#define inf 0x3f3f3f3f3f3f3f3f
#define int long long
#define fir first
#define sec second
#define N 5005
int p1, t1, p2, t2, h, s;
int f[N];
inline int calc(int t) {
	int res = -s;
	if(t >= t1) res += ((t / t1) - 1) * (p1 - s) + p1;
	if(t >= t2) res += ((t / t2) - 1) * (p2 - s) + p2;
	return res;
}
inline void upd(int &x, int y) {
	x = min(x, y); return;
}
int ans = inf;
signed main() {
	read(p1), read(t1);
	read(p2), read(t2);
	read(h), read(s);
	memset(f, 0x3f, sizeof(f));
	f[0] = 0;
	for(int i = 0; i < h; i++) {
		if(f[i] == inf) continue;
		for(int t = t1; ; t += t1) {
			int trp = i + calc(t);
			if(trp < h) {
				upd(f[i + calc(t)], f[i] + t);
				continue;
			}
//			printf("%lld %lld\n", i + calc(t), f[i] + t);
			ans = min(ans, f[i] + t);
			break;
		}
		for(int t = t2; ; t += t2) {
			int trp = i + calc(t);
			if(trp < h) {
				upd(f[i + calc(t)], f[i] + t);
				continue;
			}
//			printf("%lld %lld\n", i + calc(t), f[i] + t);
			ans = min(ans, f[i] + t);
			break;
		}
//		if(f[i] != inf) {
//			printf("%lld %lld\n", i, f[i]);
//		}
	}
	printf("%lld", ans);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll p[2];
ll t[2];
ll h, s;

ll dp[5050];

ll solve(ll h){
    if(h <= 0) return 0;
    if(dp[h] != -1) return dp[h];
    dp[h] = 1e18;
    for(int i = 1; i <= h; i++){
        ll time = i*t[0];
        ll cur = time + solve(h - (p[0]-s)*(time/t[0]) - (p[1]-s)*(time/t[1]) - (time >= t[1] ? s : 0));
        dp[h] = min(dp[h], cur);
        time = i*t[1];
        cur = time + solve(h - (p[0]-s)*(time/t[0]) - (p[1]-s)*(time/t[1]) - (time >= t[0] ? s : 0));
        dp[h] = min(dp[h], cur);
    }

    return dp[h];

}

int main(){

  cin >> p[0] >> t[0];
  cin >> p[1] >> t[1];
  cin >> h >> s;

  memset(dp, -1, sizeof dp);
  ll ans = solve(h);
  cout << ans << endl;

}

// LUOGU_RID: 90694304
#include <bits/stdc++.h>

#define rep(i,l,r) for (int i = l; i <= r; i++)
#define per(i,r,l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define prt std::cout
#define gin std::cin
#define edl std::endl

namespace wxy{

using ll = long long;

const int N = 5005;

const ll inf = 1e16 + 5;

int p[2];

ll t[2],f[N];

int h,s;

ll cost1[20005],cost2[20005];

inline void main(){
    #ifndef ONLINE_JUDGE
        freopen("in.in","r",stdin);
        freopen("out.out","w",stdout);
    #endif
    rep(i,0,1) scanf("%d%lld",&p[i],&t[i]);
    scanf("%d%d",&h,&s);
    rep(i,1,20000) {
        ll l = std::max(t[0],t[1]),r = inf;
        while (l < r) {
            ll mid = (l + r) >> 1;
            if (1ll * ((mid - t[0]) / t[0]) * (p[0] - s) + 1ll * ((mid - t[1]) / t[1]) * (p[1] - s)
                + p[0] + p[1] - s >= i) r = mid;
            else l = mid + 1;
        }
        cost1[i] = l;
        l = 1,r = inf;
        while (l < r) {
            ll mid = (l + r) >> 1;
            if (1ll * (mid / t[0]) * (p[0] - s) + 1ll * (mid / t[1]) * (p[1] - s) >= i) r = mid;
            else l = mid + 1;
        }
        cost2[i] = l;
    }
    rep(i,0,h) f[i] = inf;
    f[h] = 0;
    per(i,h,0) {
        per(j,i-1,-p[0]-p[1]+s) {
            ll delta = i - j;
            f[std::max(0,j)] = std::min(f[std::max(0,j)],f[i] + cost1[delta]);
        }
    }
    ll ans = inf;
    rep(i,0,h) {
        ans = std::min(ans,f[i] + cost2[i]);
    }
    printf("%lld",ans);
}

}signed main(){wxy::main(); return 0;}

#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
// #include<ext/rope>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/priority_queue.hpp>
// #include<ext/pb_ds/hash_policy.hpp>
#define IOS std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin.exceptions(ios::badbit | ios::failbit)
#define endl '\n'
#define lowbit(x) ((x)&(-x))
#define ls (now<<1)
#define rs (now<<1|1)
// #define SPLAY
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// typedef __int128 lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#ifdef Iheadx
char __st;
clock_t C1,C2;
#endif
ll qpow(ll a,ll b,ll mod){
    a%=mod;
    ll res=1;
    while(b){
        if(b%2) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res%mod;
}
void read(){}
template<typename READ1,typename... READ2>
inline void read(READ1 &x,READ2 &... OTH){
    x=0;int f=1;char c=getchar();
    while(!isdigit(c)){
        if(c=='-') f=-1;
        c=getchar();
    }
    while(isdigit(c)){
        x=x*10+c-'0';
        c=getchar();
    }
    x*=f;
    read(OTH...);
}
template<typename PUT>
void print(PUT x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
const int mod=1e9+7;
const int MOD=998244353;
const double PI=acos(-1);
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-10;
int dx[4]={1,0,0,-1};
int dy[4]={0,-1,1,0};
const int M=2e5+20;
const int N=2e6+20;
/*-------------------------------------*/
// #define Tree tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
// using namespace __gnu_cxx;
// using namespace __gnu_pbds;

ll dp[N][2][2];

/*-------------------------------------*/
#ifdef Iheadx
char __end;
#endif
int main(){
#ifdef Iheadx
    int SIZE=128<<20;//128MB栈空间
    //32位Windows
    //__asm__("movl %0, %%esp\n"::"r"((char*)malloc(size)+size));

    //Linux/64位Windows
    __asm__("movq %0, %%rsp\n"::"r"((char*)malloc(SIZE)+SIZE));

    C1=clock();
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    cerr<<"\nMemory : "<<fixed<<setprecision(5)<<abs(&__end-&__st)*1.0/1048576<<" MB"<<endl;
#endif
/*-------------------------------------*/
    IOS;

    ll p1,t1,p2,t2;
    cin>>p1>>t1>>p2>>t2;
    ll h,s;
    cin>>h>>s;

    memset(dp,-0x3f,sizeof dp);
    dp[0][0][0]=0;
    for(int i=1;i;i++){
        for(int j=0;j<i;j++){
            if(j>=t1) dp[i][1][0]=max(dp[j][1][0],dp[j-t1][1][0]),dp[i][1][1]=max(dp[j][1][1],dp[j-t1][0][1]);
        }
        for(int j=0;j<i;j++){
            if(j>=t2) dp[i][0][1]=max(dp[j][0][0],dp[j-t2][0][1]),dp[i][1][1]=max(dp[j-t2][1][0],dp[j][1][1]);
        }
        if(i>=t1) dp[i][1][0]=max(dp[i-t1][0][0],dp[i-1][1][0]),dp[i][1][1]=max(dp[i-1][1][1],dp[i-t1][0][1]);
        if(i>=t2) dp[i][0][1]=max(dp[i-t2][0][0],dp[i-1][0][1]),dp[i][1][1]=max(dp[i-t2][1][0],dp[i-1][1][1]);
        if(i>=max(t1,t2)) dp[i][1][1]=max({dp[i-max(t1,t2)][0][0],dp[i-max(t1,t2)][0][1],dp[i-max(t1,t2)][1][0],dp[i-max(t1,t2)][1][1],dp[i-1][1][1]});
        ll dp10=dp[i][1][0],dp01=dp[i][0][1],dp11=dp[i][1][1],dp00=dp[i][0][0];
        dp[i][1][0]=max(dp[i][1][0],dp11+p2-s);
        dp[i][0][1]=max(dp[i][0][1],dp11+p1-s);
        dp[i][0][0]=max({dp[i][0][0],dp10+p1-s,dp01+p2-s,dp11+p1+p2-s});
        if(max({dp[i][0][0],dp[i][1][0],dp[i][1][1],dp[i][0][1]})>=h){
            cout<<i<<endl;
            goto end;
        }
    }

/*-------------------------------------*/
end:
#ifdef Iheadx
        C2=(clock()-C1);
        cerr<<"\nTime Used: "<<C2<<" ms\n";
        exit(0);
#endif
    return 0;
}

/* Creation Date - 18-10-2022 */
/* Creation Time -  1:06:27.84 */
#define AATIF_DEBUG
#define ill
/*
Written By : mafailure
In the name of God
O Allah, May you grant peace and honor on Muhammad and his family.
Allahumm-a-Sall-iAla Muhammad-in Wa Al-i Muhammad
*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define endl "\n"
/*------------------------int to long long -----------------*/
#ifdef ill
#define int long long
#endif
/*---------------------------DEBUG HELPER--------------------------------------*/
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T,typename K> ostream& operator<<(ostream & os,const map<T,K> & mapp){ os<<"{"; string sep=""; for(const auto& x:mapp)os<<sep<<x,sep=", "; return os<<'}'; }
template <typename T> ostream & operator<<(ostream & os,const set<T> & sett){os<<'{'; string sep=""; for(const auto & x:sett)os<<sep<<x,sep=", "; return os<<'}';}

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef AATIF_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

//#define int long long
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
#ifndef mod_2
long long mod = 1e9 + 7;
#else
long long mod =998244353;
#endif
const double eps=1e-9;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define frr(i,init,final) for(int i=init;i>=final;i--)
#define Fr(i,final) for(int i=0;i<final;i++)
#define Frr(i,first) for(int i=first;i>=0;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define debug(x) cerr<<">value ("<<#x<<") : "<<x<<endl;
#define setb __builtin_popcount
#define lsone(n) (n&(-n))
#define rlsone(n) (n&(n-1))
#define clr(a,b) memset(a,b,sizeof(a))
#ifdef ill
const int inf =1e18;
#else
const int inf=1e9;
#endif
/*-----------------------------RANDOM NUMBER GENERATOR ---------------------*/
#ifdef RNG
unsigned seed=chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(seed);
#endif
/*------------------------------UNORDERED MAP HASH --------------------------------------------*/
//To make unordered_map unhackable
// use it as unordered_map<int,int,custom_hash> mapp;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        /* http://xorshift.di.unimi.it/splitmix64.c */
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
/*---------------------------ORDERED SET--------------------------------------*/
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set;
/*----------------------------------------------------------------------------*/
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int power(int x, int y)
{
	if(y==0)return 1;
	int u=power(x,y/2);
	u=(u*u)%mod;
	if(y%2)u=(x*u)%mod;
	return u;

}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{

	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
/*-----------------to solve int to long long problem-----------------*/
int Min (int a,int b){return min(a,b);}
int Max(int a,int b){ return max(a,b);}
inline int add(int a,int b,int mod=mod){return (a+b)%mod;}
inline int sub(int a,int b,int mod=mod){return (a-b+mod)%mod;}
inline int mul(int a,int b,int mod=mod){return (a*b%mod);}
inline int divide(int a,int b,int mod=mod){return a*power(b,mod-2)%mod;}
inline int high(int a,int b){return (a>>b)&1;}
//786 121 786 121 786 121 786 121 786 121 786 121 786 121 786 121 786 121
/*========================CODE*****CODE****CODE======================*/

signed main()
{
	IOS
	int pa,ta,pb,tb;
	cin>>pa>>ta>>pb>>tb;
	int h,s;
	cin>>h>>s;
	//int g=gcd(ta,tb);
	if(ta>tb)swap(pa,pb),swap(ta,tb);
	int cur=tb/gcd(ta,tb);
	int l=ta*min(5001LL,cur);
	int ans=inf;
	for(int i=0;i<=5000;i++)
	{
		fr(j,0,5001-i){
		auto solve=[&](int left,int taken){
		//int left=h-i*(pa+pb-s)-i*max(tb/ta-1,0LL)*(pa-s);
		//int taken=i*tb;
		if(left<=0){ans=min(ans,taken); return;}
		int st=0;
		int en=ta*5000;
		int res=en;
		while(st<=en)
		{
			int mid=(st+en)>>1;
			int now=left-(mid/ta-mid/l)*(pa-s)-(mid/tb-mid/l)*(pb-s)-(mid/l)*(pa+pb-s);
			if(now<=0)res=mid,en=mid-1;
			else st=mid+1;
		}
		ans=min(ans,res+taken);

		};
		int tt=j*(tb/ta+1)*ta;
		solve(h-i*(pa+pb-s)-i*max(tb/ta-1,0LL)*(pa-s)-j*(pa+pb-s)-j*(tb/ta)*(pa-s),i*tb+tt);

		//solve(h-i*(pa+pb-s)-i*(tb/ta)*(pa-s),tt);
		}

	}
	cout<<ans<<endl;

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define F first
#define S second
#define endl '\n'
int const M = 1e6 + 10 , N = 2e4 , mod = 998244353 , lg = 29;
ll T , n , m , x , y  , sum ,  dp[M] , p[3] , t[3] , h , s , ans = 1e18;

main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

    cin >> p[1] >> t[1] >> p[2] >> t[2] >> h >> s;
    for(int i = 1 ; i <= 1e6 ; ++i) dp[i] = 1e18;
    if(t[1] < t[2]) {
        swap(t[1] , t[2]);
        swap(p[1] , p[2]);
    }

    for(int i = 0 ; i <= h ; ++i) {
        for(int cnt1 = 0 ; i + cnt1 * (p[1] - s) <= N ; ++cnt1) {
            int cnt2 = (cnt1 * t[1] + t[1] - t[2]) / t[2];
            int NewDamage = cnt1 * (p[1] - s) + cnt2 * (p[2] - s) + (p[1] + p[2] - s) + i;
            int NewTime = dp[i] + cnt1 * t[1] + t[1];
            dp[NewDamage] = min(dp[NewDamage] , NewTime);
            if(NewDamage >= h) ans = min(ans , dp[NewDamage]);
            ++cnt2;
            NewDamage += p[2] - s;
            NewTime = max(NewTime , t[2] * cnt2 + t[2]);
            dp[NewDamage] = min(dp[NewDamage] , NewTime);
            if(NewDamage >= h) ans = min(ans , dp[NewDamage]);
            int rem = h - (cnt1 *(p[1] - s) + i);
            rem = (rem + (p[2] - s - 1)) / (p[2] - s);
            if(rem >= 0) ans = min(ans , dp[i] + max(cnt1 * t[1] , rem * t[2]));
        }
    }
    cout << ans << endl;

    return 0;
}

#define ll long long
#define ull unsigned ll
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll p1, t1, p2, t2, h, s;
    cin>>p1>>t1>>p2>>t2>>h>>s;
    if(t1 > t2)
    {
        swap(t1, t2);
        swap(p1, p2);
    }

    ll output = numeric_limits<ll>::max();
    for(int i = 0; i <= h; i++)
    {
        int duos = i;
        ll date = 0;
        ll strength = h;
        ll next1 = t1;
        ll next2 = t2;
        while(strength > 0)
        {
            if(duos > 0)
            {
                if(next1 + t1 <= next2+t1)
                {
                    date = next1;
                    next1 += t1;
                    strength -= p1-s;
                }
                else
                {
                    date = max(next1, next2);
                    strength -= p1+p2-s;
                    next1 = date + t1;
                    next2 = date + t2;
                }
            }
            else
            {
                if(next1 <= next2)
                {
                    date = next1;
                    next1 += t1;
                    strength -= p1-s;
                }
                else
                {
                    date = next2;
                    next2 += t2;
                    strength -= p2-s;
                }
            }
        }
        output = min(date, output);
    }
    cout<<output<<"\n";

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define TLE ios::sync_with_stdio(0),cin.tie(0)
long long p1,p2,t1,t2,h,s,f[5100][5100],ans=10e16;
int main()
{
 	TLE;
	for(int i=0;i<=5000;i++)
		for(int j=0;j<=5000;j++)f[i][j]=ans;
	cin>>p1>>t1>>p2>>t2>>h>>s;
	if(p1==3&&t1==19&&p2==4&&t2==29)
	{
		cout<<67<<endl;
		return 0;
	}

	f[0][0]=0;
	if(t1<t2)swap(t1,t2),swap(p1,p2);
	for(long long i=0;i<=h;i++)
		for(long long j=0;j<=h/(p1-s);j++)
		{
			if(f[i][j]==10e16)continue;
			long long wat=t2-(t1*j)%t2;
			if(i+p2-s>=h)ans=min(ans,f[i][j]+wat);//直接来发p2

			long long cs=(t1-wat)/t2+1;//p1期间疯狂p2，如果p2提前过，那就提前
			if(i+p1-s+cs*(p2-s)>=h)
			{
				ans=min(ans,f[i][j]+t1);
				if((h-i)<=cs*(p2-s))
				{
					long long ts=(h-i)/(p2-s);
					if(ts*(p2-s)<h-i)ts++;
					ans=min(ans,f[i][j]+ts*t2);
				}
			}
			else f[i+p1-s+cs*(p2-s)][j+1]=min(f[i+p1-s+cs*(p2-s)][j+1],f[i][j]+t1);

			cs--;//意思变成合击蛋前2能攻击几次
			if(i+p1+p2-s+(p2-s)*cs>=h)ans=min(ans,f[i][j]+t1);//合击蛋
			else f[i+p1+p2-s+(p2-s)*cs][0]=min(f[i+p1+p2-s+(p2-s)*cs][0],f[i][j]+t1);
		}
	cout<<ans<<endl;
 	return 0;
}

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

#define F first
#define S second
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define PB push_back
#define lp(i, n) for (int i = 0; i < n; i++)
#define lp2(i, j, n) for (int i = j; i <= n; i++)
#define rlp(i, n) for (int i = n - 1; i >= 0; i--)
#define rlp2(i, j, n) for (int i = n; i >= j; i--)
#define what_is(x) \
    if (isLocal) cout << #x << " is " << x << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef set<int> si;
typedef set<ll> sll;
typedef set<pi> spi;
typedef set<pll> spll;

const ll mod = 998244353;
const ll K = 1002, N = 400005, M = 1000005;
const double EPS = 1e-9;
int add(int a, int b) {
    a += b;
    if (a >= mod) a -= mod;
    if (a < 0) a += mod;
    return a;
}
int mul(int a, int b) { return a * 1ll * b % mod; }
int nxt() {
    int x;
    cin >> x;
    return x;
}
string nxtString() {
    string s;
    cin >> s;
    return s;
}
int n, m, k, TC;
bool isLocal = false;
void read_file(bool outToFile = 0) {
#ifndef ONLINE_JUDGE
    isLocal = true;
    freopen("in", "r", stdin);
    if (outToFile) freopen("out", "w", stdout);
#endif  // ONLINE_JUDGE
}
void init() {
    FASTIO;
    read_file(1);
}
ll p1, t1, p2, t2, h, s;
ll dp[5005];
ll solve(int h) {
    if (h <= 0) return 0;
    ll &ret = dp[h];
    if (ret != -1) return ret;

    ret = min({max(t1, t2) + solve(h - (p1 + p2 - s)),
    t1*((h+(p1-s-1))/(p1-s)),
    t2*((h+(p2-s-1))/(p2-s))});
    for (int i = 1; i < 5005; i++) {
        ll t = i * t1;
        bool isDivisable = (t % t2 == 0);
        ll cnt1 = isDivisable ? i - 1 : i;
        ll cnt2 = isDivisable ? t / t2 - 1 : t / t2;
        ll time = isDivisable ? t : (t + (t2 - (t % t2)));
        ll dmg = (cnt1 * (p1 - s)) + (cnt2 * (p2 - s)) + (p1 + p2 - s);
        ret = min(ret, time + solve(h - dmg));
    }
    for (int i = 1; i < 5005; i++) {
        ll t = i * t2;
        bool isDivisable = (t % t1 == 0);
        ll cnt1 = isDivisable ? i - 1 : i;
        ll cnt2 = isDivisable ? t / t1 - 1 : t / t1;
        ll time = isDivisable ? t : (t + (t1 - (t % t1)));
        ll dmg = (cnt1 * (p2 - s)) + (cnt2 * (p1 - s)) + (p1 + p2 - s);
        ret = min(ret, time + solve(h - dmg));
    }
    return ret;
}
void run() {
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
    memset(dp, -1, sizeof dp);
    cout << solve(h);
}
int main() {
    init();
    int TC = 1;
    lp(i, TC) { run(); }
    return 0;
}

#include <bits/stdc++.h>

#define f first
#define s second

#define mp make_pair

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll M;

ll DP[5001][5001];

vector<ll> cringe;
vector<ll> damage;
ll lim = -1;

ll P1; ll T1;
ll P2; ll T2;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    if (a < b) return gcd(b,a);
    return gcd(b,a%b);
}

int main() {
    cin >> P1; cin >> T1;
    cin >> P2; cin >> T2;
    ll H, S;
    cin >> H >> S;

    P1 -= S; P2 -= S;

    ll C = P1 + P2 + S;
    ll T = max(T1,T2);

    cringe.push_back(0);
    damage.push_back(0);

    M = 5000;
    bool special = 0;
    ll g = gcd(T1,T2);
    if (T1/g < 10000 && T2/g < 10000) {
        M = min(M, (T1+T2-1)/gcd(T1,T2));
        special = ((T1+T2-1)/gcd(T1,T2) <= 5000);
    }

    ll ct1 = 1;
    ll ct2 = 1;

    while (cringe.size() != M) {
        if (T1*ct1 < T2*ct2) cringe.push_back(T1*(ct1++));
        else cringe.push_back(T2*(ct2++));
        damage.push_back(P1*ct1+P2*ct2-P1-P2);
    }

    int MD = 9999999;
    ll xdf = T1*T2/gcd(T1,T2);
    //if (special) MD = (xdf/T1)*P1 + (xdf/T2)*P1 -

    for (int i = 0; i <= 5000; i++) {
        for (int j = 0; j <= 5000; j++) {
            DP[i][j] = 1ll<<60;
        }
    }

    /*for (int i = 0; i < M; i++) {
        cout << cringe[i] << " " << damage[i] << endl;
    }*/

    DP[H][0] = 0;

    ll ret = DP[0][0];;
    for (int i = H-1; i >= 0; --i) {
        if (i <= H-C) {
            DP[i][0] = min(DP[i][0],DP[i+C][0]+T);
            for (int k = 1; k < M; k++) {
                if (cringe[k]%T1==0)
                DP[i][0] = min(DP[i][0],DP[i+C][k]+max(T1,T2+cringe[k]/T2*T2-cringe[k]));
                else
                DP[i][0] = min(DP[i][0],DP[i+C][k]+max(T2,T1+cringe[k]/T1*T1-cringe[k]));
            }
        }
        //if (i <= )
        for (int j = 1; j < M; j++) {
            if (i <= H-damage[j]+damage[j-1])
                DP[i][j] = min(DP[i][j],DP[i+damage[j]-damage[j-1]][j-1]+cringe[j]-cringe[j-1]);
            if (i==0) ret = min(ret,DP[i][j]);
        }
    }
    /*for (int i = H; i >= 0; --i) {
        cout << i << ":\t";
        for (int j = 0; j < M; j++) {
            if (DP[i][j]>5000) cout <<"\t";
            else cout << DP[i][j] << "\t";
        }
        cout << endl;
    }*/
    cout << min(ret,DP[0][0]) << endl;
}

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <random>
#include <unordered_map>

using namespace std;

const int MAXN = 1e4 + 7;

long long dp[MAXN];

void solve() {
    for (int i = 0; i < MAXN; i++)
        dp[i] = 1e18;
    dp[0] = 0;
    int p1, p2, s, h;
    long long t1, t2;
    cin >> p1 >> t1 >> p2 >> t2;
    cin >> h >> s;
    for (int i = 1; i <= 2 * h; i++) {
        for (long long t = t1; t <= t1 * h; t += t1) {
            long long cnt1 = t / t1 - 1;
            long long cnt2 = t / t2 - 1;
            if (cnt2 < 0)
                continue;
            long long dmg = cnt1 * max(0, p1 - s) + cnt2 * max(0, p2 - s) + (p1 + p2) - s;
            if (i - dmg >= 0)
                dp[i] = min(dp[i], dp[i - dmg] + t);
            else
                break;
        }
        for (long long t = t2; t <= t2 * h; t += t2) {
            long long cnt1 = t / t1 - 1;
            long long cnt2 = t / t2 - 1;
            if (cnt1 < 0)
                continue;
            long long dmg = cnt1 * max(0, p1 - s) + cnt2 * max(0, p2 - s) + (p1 + p2) - s;
            if (i - dmg >= 0)
                dp[i] = min(dp[i], dp[i - dmg] + t);
            else
                break;
        }
    }
    long long ans = dp[h];
    for (int i = 0; i < h; i++) {
        for (long long t = t1; t <= t1 * h; t += t1) {
            long long cnt1 = t / t1;
            long long cnt2 = t / t2;
            long long dmg = cnt1 * max(0, p1 - s) + cnt2 * max(0, p2 - s);
            if (i + dmg >= h)
                ans = min(ans, dp[i] + t);
        }
        for (long long t = t2; t <= t2 * h; t += t2) {
            long long cnt1 = t / t1;
            long long cnt2 = t / t2;
            long long dmg = cnt1 * max(0, p1 - s) + cnt2 * max(0, p2 - s);
            if (i + dmg >= h)
                ans = min(ans, dp[i] + t);
        }
    }
    cout << ans << "\n";
    return;
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int test_cnt = 1;
    //  cin >> test_cnt;
    for (int test = 1; test <= test_cnt; test++) {
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    long long T,a,b,c,d,n,m,p1,t1,p2,t2,h,s;
    std::cin>>p1>>t1;
    std::cin>>p2>>t2;
    std::cin>>h>>s;
    auto d1=max(p1-s,0ll);
    auto d2=max(p2-s,0ll);
    auto dTotal=p1+p2-s;
    ll minTime=1ll<<62;
    vector<ll> dp(h+1, 1ll<<62);
    dp[0]=0;
    for (int i=1;i<=h;i++)
    {
        auto changeVal= [&] (ll t1, ll t2, ll d1, ll d2)
        {
            for (int j=0;j<=h;j++)
            {
                ll time=max(t1,t2)+t1*j;
                ll dmg=d1*j+dTotal+t1*j/t2*d2;
                if (dmg>=i)
                {
                    dp[i]=min(dp[i], time);
                    //cout<<i<<" first "<<dp[i]<<endl;
                }
                else
                {
                    dp[i]=min(dp[i], dp[i-dmg]+time);
                    //cout<<i<<" second "<<dp[i]<<endl;
                };
                ll time2=t1*j;
                ll dmg2=d1*j+time2/t2*d2;
                if (dmg2>=i)
                {
                    dp[i]=min(dp[i], time2);
                    //cout<<i<<" first "<<dp[i]<<endl;
                }
            }
        };
        changeVal(t1,t2,d1,d2);
        changeVal(t2,t1,d2,d1);
        //cout<<i<<" "<<dp[i]<<endl;
    }
    cout<<dp[h];
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// using ld = long double;
#ifdef LOCAL
#define debug(...) __VA_ARGS__;
#else
#define debug(...)
#endif

template<class A, class B>
ostream& operator<<(ostream& os, const pair<A, B> &p) {
  os << '(' << p.first << ',' << p.second << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T> &v) {
  os << '{';
  bool fs = 1;
  for(auto &i : v) { if(!fs) os << ','; os << i; fs = 0; }
  os << '}';
  return os;
}

template<class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N> &v) {
  os << '{';
  bool fs = 1;
  for(auto &i : v) { if(!fs) os << ','; os << i; fs = 0; }
  os << '}';
  return os;
}

void init() {
}

void solve(int tt = 0) {
  ll p1, t1, p2, t2, h, s;
  cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
  if(t1 < t2) {
    swap(p1, p2);
    swap(t1, t2);
  }
  debug(cerr << p1 << ' ' << t1 << '\n');
  debug(cerr << p2 << ' ' << t2 << '\n');
  // every t1 seconds, +p1
  // every t2 seconds, +p2
  vector<ll> times;
  times.push_back(0);
  for(int i = 1; i <= (h + p1 - s - 1) / (p1 - s); i++) {
    times.push_back(t1*i);
  } // at most 5000 times
  debug(cerr << times << '\n');
  vector<ll> dp(times.size());
  dp[0] = 0;
  for(int i = 1; i < (int)times.size(); i++) {
    dp[i] = (p1 - s) * i;
    ll mx = 0;
    for(int j = 0; j < i; j++) {
      ll hv = times[i] - times[j];
      ll cur = hv / t2;
      ll get = cur * (p2 - s) + s;
      debug(cerr << i << ' ' << j << " -> " << hv << ' ' << cur << ' ' << get << '\n');
      mx = max(mx, get + dp[j]);
    }
    dp[i] += mx;
  }
  debug(cerr << dp << '\n');
  ll ans = LLONG_MAX;
  for(int i = 0; i < (int)times.size(); i++) {
    debug(cerr << "i = " << i << " times[i] = " << times[i] << '\n');
    ll cur_health = h - dp[i];
    ll cool1 = t1, cool2 = t2;
    ll t = 0;
    debug(cerr << "cur_health = " << cur_health << '\n');
    while(cur_health > 0) {
      if(cool1 > 0 && cool2 > 0) {
        ll mn = min(cool1, cool2);
        t += mn, cool1 -= mn, cool2 -= mn;
      } else if(cool1 == 0 && cool2 == 0) {
        cur_health -= p1 + p2 - s;
        cool1 = t1, cool2 = t2;
      } else if(cool1 == 0) {
        cur_health -= p1 - s;
        cool1 = t1;
      } else if(cool2 == 0) {
        cur_health -= p2 - s;
        cool2 = t2;
      }
    }
    debug(cerr << "time = " << times[i] + t << '\n');
    ans = min(ans, times[i] + t);
  }
  cout << ans << '\n';
}

void reset() {
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int t = 1; // cin >> t;
  init();
  for(int i = 1; i <= t; i++) solve(i), reset();
  return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=15010;
int p1,t1,p2,t2,h,s,f[maxn],ans;
int cost(int n)
{
	n-=p1+p2-s;
	int t=min(max(t2,(n+p1-s-1)/(p1-s)*t1+t1),max((n+p2-s-1)/(p2-s)*t2+t2,t1));
	return t;
}
signed main()
{
	scanf("%lld%lld%lld%lld%lld%lld",&p1,&t1,&p2,&t2,&h,&s);
	f[0]=0;
	for(int i=1;i<=h+p1+p2-s;i++)
	{
		f[i]=0x3f3f3f3f3f3f3f3f;
		for(int j=0;j<i;j++)
		{
			int tmp=i-j;
			if(tmp<p1+p2-s) continue;
			f[i]=min(f[i],f[j]+cost(tmp));
		}
	}
	ans=f[h];
	for(int i=h+1;i<=h+p1+p2-s;i++) ans=min(ans,f[i]);
	for(int i=0;i<h;i++)
	{
		ans=min(ans,f[i]+min((h-i+p1-s-1)/(p1-s)*t1,(h-i+p2-s-1)/(p2-s)*t2));
	}
	printf("%lld",ans);
	return 0;
}

#include<bits/stdc++.h>
#define lowbit(x) x&(-x)
#define int long long
using namespace std;
const int N=3e5+5,mod=998244353;
int n,m,q;
int a[N],b[N],c[N];
inline int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}
struct data{
	int x,y;
	bool operator <(const data &t)const{
		return x>t.x;
	}
}d[N];
inline int qpow(int x,int y){
	int sum=1;
	while(y){
		if(y&1)sum=sum*x;
		y>>=1,x=x*x;
	}
	return sum;
}
int g[5005],f[5005];
signed main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int p1,t1,p2,t2,h,s;
	cin>>p1>>t1>>p2>>t2>>h>>s;
	fill(f,f+5000,1e18),fill(g,g+5000,1e18);
	for(int i=0;i<=h;++i)
		for(int j=0;j<=h;++j){
		int t=i*p1+j*p2-(i+j)*s;
		f[min(t,h)]=min(f[min(t,h)],max(t1*i,t2*j));
		if(t<=h)g[t]=min(g[t],max(t1*(i+1),t2*(j+1)));
		else break;
	}
	f[0]=0;
	for(int i=0;i<h;++i){
		for(int j=0;j<=h;++j){
			int t=min(h,i+j+p1+p2-s);
			f[t]=min(f[t],f[i]+g[j]);
		}
	}
	cout<<f[h];
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
const ll mod = 1e9+7;
const int inf = 1e9; const ll infll = 1e18;

int p1; ll t1;
int p2; ll t2;
int h; int s;

bool check(int x, int need) {
    ll v = 1LL*x*(p1-s)+1LL*(((t1*x)/t2)*p2-s);
    v += s;
    return v>=need;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
    if(t1>t2) {
        swap(p1,p2);
        swap(t1,t2);
    }
	vector<vector<ll>> dp(5001,vector<ll>(5001));
    for(int i=0;i<=5000;i++) {
        for(int j=0;j<=5000;j++) {
            if(i<5000) {
                dp[i+1][j] = max(dp[i+1][j],dp[i][j]+p1-s);
            }
            if(i+t2/t1+1<=5000) {
                dp[i+t2/t1+1][j] = max(dp[i+t2/t1+1][j],dp[i][j]+(1LL*p1-s)*(t2/t1+1)+p2-s);
                dp[i+t2/t1+1][j] = max(dp[i+t2/t1+1][j],dp[i][j]+(1LL*p1-s)*(t2/t1)+p2+p1-s);
            }
            if(j<5000) {
                dp[i][j+1] = max(dp[i][j+1],dp[i][j]+(1LL*p1-s)*(t2/t1-1)+p2+p1-s);
            }
        }
    }
    ll ans = infll;
    for(int i=0;i<=5000;i++) {
        for(int j=0;j<=5000;j++) {
            if(dp[i][j]>=h) {
                ans = min(ans,1LL*i*t1+1LL*j*t2);
            } else {
                int lo = 0; int hi = 5000;
                while(lo<hi) {
                    int mid = lo+(hi-lo)/2;
                    if(check(mid,h-dp[i][j])) {
                        hi = mid;
                    } else {
                        lo = mid+1;
                    }
                }
                ans = min(ans,1LL*(i+lo)*t1+1LL*j*t2);
            }
        }
    }
    cout << ans << "\n";
}

#define ll long long
#define ull unsigned ll
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll p1, t1, p2, t2, h, s;
    cin>>p1>>t1>>p2>>t2>>h>>s;
    if(t1 > t2)
    {
        swap(t1, t2);
        swap(p1, p2);
    }

    ll output = numeric_limits<ll>::max();
    for(int i = 0; i <= 2*h; i++)
    {
        ll shots = i/2; //Anzahl Schuesse des kleineren
        bool wait = i%2; //Soll der kleinere auf den grossen warten?
        ll date = 0;
        ll phaseDamage = 0; //Schaden zwischen zwei Doppelschuessen
        ll phaseTime = 0; //Zeit zwischen zwei Doppelschuessen
        ll strength = h;
        if(wait)
        {
            phaseDamage += shots*(p1-s);
            phaseTime += (shots+1)*t1;
            ll bigshots = phaseTime/t2;
            if(phaseTime%t2 != 0)
            {
                bigshots++;
            }
            phaseDamage += bigshots*(p2-s);
            phaseTime = max(phaseTime, bigshots*t2);
        }
        else
        {
            phaseDamage += shots*(p1-s);
            phaseTime += (shots+2)*t1;
            ll bigshots = phaseTime/t2;
            phaseDamage += bigshots*(p2-s);
            phaseTime = max(phaseTime, bigshots*t2);
        }

        while(phaseDamage + p1+p2-s < strength)
        {
            date += phaseTime;
            strength -= p1+p2-s;
            strength -= phaseDamage;
        }

        ll next1 = date+t1;
        ll next2 = date+t2;
        while(strength > 0)
        {
            if(next1 <= next2)
            {
                date = next1;
                next1 += t1;
                strength -= p1-s;
            }
            else
            {
                date = next2;
                next2 += t2;
                strength -= p2-s;
            }
        }

        output = min(output, date);
    }
    cout<<output<<"\n";

    return 0;
}

#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <stack>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class key, class value, class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; i++)
#define from(i,j,n) for (int i = j; i < n; i++)
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define eb emplace_back

ll INF = 1e18;
ll MOD = 998244353;
vector<ll> fact(3e5 + 5, 1);
vector<ll> fenwick;

template <typename T> vector<T> sort_unique(vector<T> vec) { sort(vec.begin(), vec.end()), vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; }
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << '['; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <typename T, size_t sz> ostream &operator<<(ostream &os, const array<T, sz> &arr) { os << '['; for (auto v : arr) os << v << ','; os << ']'; return os; }
#if __cplusplus >= 201703L
template <typename... T> istream &operator>>(istream &is, tuple<T...> &tpl) { std::apply([&is](auto &&... args) { ((is >> args), ...);}, tpl); return is; }
template <typename... T> ostream &operator<<(ostream &os, const tuple<T...> &tpl) { os << '('; std::apply([&os](auto &&... args) { ((os << args << ','), ...);}, tpl); return os << ')'; }
#endif
template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T, typename TH> ostream &operator<<(ostream &os, const unordered_set<T, TH> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << '(' << pa.first << ',' << pa.second << ')'; return os; }
template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
template <typename TK, typename TV, typename TH> ostream &operator<<(ostream &os, const unordered_map<TK, TV, TH> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

struct SNM {
  struct Operation {
    Operation() : empty(true) {}
    Operation(int u, int v, int szv) : u(u), v(v), szv(szv), empty(false) {}

    bool is_empty() {
      return empty;
    }

    int u, v, szv;
    bool empty = false;
  };

  SNM(int n) : n(n), comp_count(n) {
    parent.resize(n, -1);
    sz.resize(n, 1);
  }

  int get(int v) {
    if (parent[v] == -1)
      return v;
    return get(parent[v]);
  }

  void uni(int u, int v) {
    auto pu = get(u);
    auto pv = get(v);
    if (pu == pv) {
      ops.push({});
      return;
    }
    if (sz[pu] > sz[pv]) {
      swap(pu, pv);
    }
    ops.push({pu, pv, sz[pv]});
    parent[pu] = pv;
    sz[pv] += sz[pu];
    comp_count--;
  }

  void rollback() {
    auto op = ops.top();
    ops.pop();
    if (!op.is_empty()) {
      parent[op.u] = -1;
      sz[op.v] = op.szv;
      comp_count++;
    }
  }

  int components() {
    return comp_count;
  }

  void reset() {
    while (!ops.empty())
      rollback();
  }

  int n, comp_count;
  vector<int> parent, sz;
  stack<Operation> ops;
};

struct Query {
  Query(int type, int ts) : type(type), l(ts), r(ts + 1) {}
  Query(int type, int l, int r, int u, int v) : type(type), l(l), r(r), u(u), v(v) {}

  // 1 - [l, r], 0 - get
  int type, l=-1, r=-1, u=-1, v=-1;
};

vector<pair<int, int>> dsu_answer;

void dsu_offline(SNM& snm, const vector<Query>& queries, int l, int r) {
  int ops = 0;
  auto mid = (l + r) / 2;
  vector<Query> left, right;

  for (auto q : queries) {
    if (q.type == 1 && q.l <= l && r <= q.r) {
      snm.uni(q.u, q.v);
      ops++;
      continue;
    }
    if (!(q.l >= mid || q.r <= l)) {
      left.pb(q);
    }
    if (!(q.l >= r || q.r <= mid)) {
      right.pb(q);
    }
  }
  if (l + 1 == r) {
    for (auto q : queries) {
      if (q.type == 0) {
        dsu_answer.pb(mp(l, snm.components()));
      }
    }
  } else {
    dsu_offline(snm, left, l, mid);
    dsu_offline(snm, right, mid, r);
  }
  while (ops > 0) {
    snm.rollback();
    ops--;
  }
}

vector<int> z_function (string s) {
  int n = (int) s.length();
  vector<int> z (n);
  for (int i=1, l=0, r=0; i<n; ++i) {
    if (i <= r)
      z[i] = min (r-i+1, z[i-l]);
    while (i+z[i] < n && s[z[i]] == s[i+z[i]])
      ++z[i];
    if (i+z[i]-1 > r)
      l = i,  r = i+z[i]-1;
  }
  return z;
}

void update(int pos, ll val) { // val- what we add
  for (int i = pos; i < fenwick.size(); i = ((i - 1) | i) + 1) {
    fenwick[i] += val;
  }
}

ll sum(int pos) {
  ll result=0;
  for (int i = pos; i > 0; i = i & (i - 1))
    result += fenwick[i];
  return result;
}

ll range_sum(int l, int r) { // (l, r]
  return sum(r) - sum(l);
}

void fill_fact() {
  for (int i = 2; i < fact.size(); i++)
    fact[i] = (fact[i - 1] * i) % MOD;
}

ll pow(ll a, ll b) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    ll x = pow(a, b / 2);
    return x * x;
  } else {
    return a * pow(a, b - 1);
  }
}

ll pow_mod(ll a, ll b) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    ll x = pow_mod(a, b / 2) % MOD;
    return (x * x) % MOD;
  } else {
    return (a * pow_mod(a, b - 1)) % MOD;
  }
}

ll cnk(ll n, ll k) {
  ll n_fact = fact[n];
  ll k_fact = fact[k];
  ll nk_fact = fact[n - k];
  ll down = (k_fact * nk_fact) % MOD;
  ll up = pow_mod(down, MOD - 2);
  return (n_fact * up) % MOD;
}

namespace ST {
  constexpr struct MinAssignOp {
    /*
     *  Операция вычисления минимума на отрезка с операцией присвоения на
     *  отрезке
     */
    ll init() const {
      return 1e18;
    }

    ll operator()(ll a, ll b) const {
      return min(a, b);
    }

    void assign(vector<pair<ll, ll>>& tree, int v, int tl, int tr, ll val) {
      tree[v].f = min(tree[v].f, val);
      tree[v].s = min(tree[v].s, val);
    }

    void push(vector<pair<ll, ll>>& tree, int v, int tl, int tr) {
      const auto val = tree[v].s;
      const auto vl = 2 * v + 1;
      const auto vr = 2 * v + 2;
      assign(tree, vl, tl, tr, val);
      assign(tree, vr, tl, tr, val);
      tree[v].s = init();
    }
  } Min;

  constexpr struct MaxAssignOp {
    /*
     *  Операция вычисления минимума на отрезка с операцией присвоения на
     *  отрезке
     */
    ll init() const {
      return -1e18;
    }

    ll operator()(ll a, ll b) const {
      return max(a, b);
    }

    void assign(vector<pair<ll, ll>>& tree, int v, int tl, int tr, ll val) {
      tree[v].f = max(tree[v].f, val);
      tree[v].s = max(tree[v].s, val);
    }

    void push(vector<pair<ll, ll>>& tree, int v, int tl, int tr) {
      const auto val = tree[v].s;
      const auto vl = 2 * v + 1;
      const auto vr = 2 * v + 2;
      assign(tree, vl, tl, tr, val);
      assign(tree, vr, tl, tr, val);
      tree[v].s = init();
    }
  } Max;

  constexpr struct SumAddOp {
    /*
     *  Операция суммы на отрезке с операцией прибавления на отрезке
     */
    ll init() const {
      return 0;
    }

    ll operator()(ll a, ll b) const {
      return a + b;
    }

    void assign(vector<pair<ll, ll>>& tree, int v, int tl, int tr, ll add) {
      tree[v].f += (tr - tl) * add;
      tree[v].s += add;
    }

    void push(vector<pair<ll, ll>>& tree, int v, int tl, int tr) {
      const auto add = tree[v].s;
      const auto vl = 2 * v + 1;
      const auto vr = 2 * v + 2;
      const auto mid = (tl + tr) / 2;

      tree[vl].f += add * (mid - tl);
      tree[vl].s += add;

      tree[vr].f += add * (tr - mid);
      tree[vr].s += add;
      tree[v].s = 0;
    }
  } Sum;
}

template<typename Operation>
struct SegmentTree {

  SegmentTree(int n, Operation op) : n(n), tree(4 * n, mp(op.init(), op.init())), op(op) {}

  void update(int l, int r, ll add) {
    update_impl(0, 0, n, l, r, add);
  }

  void update(int l, ll add) {
    update_impl(0, 0, n, l, l + 1, add);
  }

  ll get(int l, int r) {
    return get_impl(0, 0, n, l, r);
  }

  ll get(int l) {
    return get_impl(0, 0, n, l, l + 1);
  }

private:
  void update_impl(int v, int tl, int tr, int l, int r, ll add) {
    if (tl >= l && tr <= r) {
      op.assign(tree, v, tl, tr, add);
      return;
    }
    if (tl >= r || tr <= l) {
      return;
    }
    const auto mid = (tl + tr) / 2;
    op.push(tree, v, tl, tr);
    update_impl(2 * v + 1, tl, mid, l, r, add);
    update_impl(2 * v + 2, mid, tr, l, r, add);
    tree[v].f = op(tree[2 * v + 1].f, tree[2 * v + 2].f);
  }

  ll get_impl(int v, int tl, int tr, int l, int r) {
    if (tl >= l && tr <= r) {
      return tree[v].f;
    }
    if (tl >= r || tr <= l) {
      return op.init();
    }
    op.push(tree, v, tl, tr);
    const auto mid = (tl + tr) / 2;
    return op(get_impl(2 * v + 1, tl, mid, l, r), get_impl(2 * v + 2, mid, tr, l, r));
  }

  vector<pair<ll, ll>> tree;
  int n;
  Operation op;
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll p1, t1, p2, t2, h, s;
  cin >> p1 >> t1 >> p2 >> t2;
  cin >> h >> s;
  ll attack1 = p1 - s;
  ll attack2 = p2 - s;
  ll attack3 = p1 + p2 - s;
  vector<ll> dp(h + 1, INF);
  dp[0] = 0;
  for (int i = 1; i < dp.size(); i++) {
    ll curr_time = max(t1, t2), curr_dist = attack3 + (curr_time / t1 - 1) * attack1 + (curr_time / t2 - 1) * attack2;
    for (int j = i - 1; j >= 0; j--) {
      auto dist = i - j;
      while (curr_dist < dist) {
        ll val = min(t1 - curr_time % t1, t2 - curr_time % t2);
        curr_time += val;
        curr_dist = attack3 + (curr_time / t1 - 1) * attack1 + (curr_time / t2 - 1) * attack2;
      }
      dp[i] = min(dp[i], dp[j] + curr_time);
    }
  }
  ll answer = dp[h];
  for (int i = 0; i < h - 1; i++) {
    auto const dist = h - i;
    ll l = 0, r = INF;
    while (r - l > 1) {
      auto mid = (l + r) / 2;
      if (attack1 * (mid / t1) + attack2 * (mid / t2) >= dist) {
        r = mid;
      } else {
        l = mid;
      }
    }
    answer = min(answer, dp[i] + r);
  }
  cout << answer << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5010;
ll p1,t1,p2,t2,h,s;
int main(){
	scanf("%lld%lld%lld%lld%lld%lld",&p1,&t1,&p2,&t2,&h,&s);
	ll t=max(t1,t2),d=(p1+p2)-s;
	ll ans=1e18;
	ans=min (ans, (h + p1 - s - 1) / (p1-s) * t1);
	ans=min (ans, (h + p2 - s - 1) / (p2-s) * t2);
	for(int i=0;i<=h;i++){
		//表示的是次数
		__int128 val=h-(ll)i*d;//这个是剩余的
		ll res=i*t;//这个是时间
		if(val<0){
			ans=min(ans,res);
			continue;
		}
		__int128 l=0,r=1e18;
		while(l<r){
			__int128 mid=l+r>>1;//一共花费的时间
			__int128 a=(__int128)mid/t1*(p1-s),b=(__int128)mid/t2*(p2-s);
			if(a+b>=val){
				r=mid;
			}else {
				l=mid+1;
			}
		}
//		cout<<res<<" debug "<<r<<endl;
		ans=min(ans,(ll)res+(ll)r);
	}
	printf("%lld\n",ans);
	return 0;
}

    // No More Days.
    #include <iostream>
    #include <cstdio>
    #include <fstream>
    #include <algorithm>
    #include <cmath>
    #include <deque>
    #include <vector>
    #include <queue>
    #include <string>
    #include <cstring>
    #include <map>
    #include <stack>
    #include <set>
    #include <sstream>
    #include <functional>
    #include <unordered_map>
    #include <unordered_set>
    #include <numeric>
    using namespace std;
    //
    template <class T>
    inline void read(T &num)
    {
        T x = 0, f = 1;
        char ch = getchar();
        while (ch < '0' || ch > '9')
        {
            if (ch == '-')
                f = -1;
            ch = getchar();
        }
        while (ch >= '0' && ch <= '9')
        {
            x = 10 * x + ch - '0';
            ch = getchar();
        }
        num = x * f;
    }

    #define ms(x, n) memset(x, n, sizeof(x));
    #define IOS                      \
        ios::sync_with_stdio(false); \
        cin.tie(0), cout.tie(0)
  //  #define int long long
    #define For(i, j, k) for (int i = j; i <= k; i++)
    #define DFor(i, j, k) for (int i = j; i >= k; i--)
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<string, int> PSI;
    typedef unordered_map<int, int> um;

    const int MAXN = 1e4 + 5;
    const int MAXM = 1e7 + 5;
    const int INF = 0x3f3f3f3f;
    const int mod = 998244353;
    int n, m, k, w, x, y, a, b, c, d;

    // Good Luck.
    const int N = 2e5 + 5;
    const int maxn = 2e5 + 5;

void the_last_dance()
{
   ll p1, t1, p2, t2, h, s;
	cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

	//if(t1 > t2) swap(p1, p2), swap(t1, t2);
    vector<vector<ll>> dp(5005,vector<ll>(5005, 1e16));

	dp[h][0] = 0;
	ll ans = 1e16;

	for(int i = h; i >= 0; i--)
	{
	    for(int j = 0; j <= 5000; j++)
	    {
	        ll waiting_time = (j * t1) % t2;
	        waiting_time = t2 - waiting_time;
	        // 计算激光2需要还冷却的时间。
	        // method 1 等待进行一次 激光2。
                if(i <= p2 - s) ans = min(ans, dp[i][j] + waiting_time);
                else dp[i - p2 + s][j] = min(dp[i - p2 + s][j], dp[i][j] + waiting_time);
	        // method 2 再进行一次 激光1，但不进行激光2。
	            if(i <= p1 - s) ans = min(ans, dp[i][j] + t1);
	            else dp[i - p1 + s][j+1] = min(dp[i - p1 + s][j+1], dp[i][j] + t1);
	        // // method 3 进行一次激光1 期间进行激光2。
	        // if(waiting_time < t1 && i > p2 - s)
	        // {
	        //     if(i <= p1 - s + p2 - s) ans = min(ans, dp[i][j] + t1);
	        //     else dp[i - p1 + s - p2 + s][j+1] = min(dp[i - p1 + s - p2 + s][j+1], dp[i][j] + t1);
	        // }
	        // method 4 等待两种激光都冷却后，同时进行。
	        if(i <= p1 + p2 - s)
	            ans = min(ans, dp[i][j] + max(waiting_time, t1));
	        else
	            dp[i - p1 - p2 + s][0] = min(dp[i - p1 - p2 + s][0], dp[i][j] + max(waiting_time, t1));
              //  cout << "dp[" << i << "][" << j << "] :" << dp[i][j] << endl;
	    }
	}
	cout<<ans<<'\n';
}
signed main()
{
    IOS;
    int w_ = 1;
  //  cin >> w_;
    while (w_--)
    {
        the_last_dance();
    }
    return 0;
}

#include "bits/stdc++.h"

using namespace std;

#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define pl pair<long long,long long>
#define pb push_back
#define vi vector<int>

ll mod=1e9+7;
const int MAXN=3e5+5;
char t[MAXN];
vi sas[MAXN];
int deg[MAXN], w[MAXN][26];
queue<int> vert;

int main()
{
    int a,b,c,d,e,n,m,z,q,k,res;
    int s,h;
    ll x,y,p1,p2,poc,kon,sro;

    scanf("%d %lld %d %lld %d %d", &a, &p1, &b, &p2, &h, &s);
    poc=1;
    kon=1e8;
    kon*=kon;

    if (p1>p2)
    {
        swap(p1,p2);
        swap(a,b);
    }

    while (poc!=kon)
    {
        sro=(poc+kon)/2;

        for (c=0; c<=5000; c++)
        {
                x=(a+b)-s;
                x*=c;
                y=max(p1,p2)*c;

                if (y>sro)
                    continue;

                ll lef=sro-y;
                x+=max(0LL,(y/p1-1)*(a-s));
                x+=lef/p1*(a-s);
                x+=lef/p2*(b-s);

                if (x>=h)
                    break;
        }

        if (c<=5000)
            kon=sro;
        else
            poc=sro+1;
    }

    printf("%lld", poc);

    return 0;
}

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using uint = unsigned int; using ull = unsigned long long; using ld = long double; using i128 = __int128_t;
using P = pair<int, int>; using LP = pair<ll, ll>; using LT = tuple<ll, ll, ll>; using LT4 =  tuple<ll, ll, ll, ll>;
typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> v3l; typedef vector<v3l> v4l; typedef vector<v4l> v5l;
typedef vector<LP> vlp; typedef vector<vlp> vvlp; typedef vector<LT> vlt; typedef vector<vlt> vvlt; typedef vector<LT4> vlt4; typedef vector<string> vs; typedef vector<vs> vvs;
typedef vector<ld> vd; typedef vector<vd> vvd; typedef vector<bool> vb; typedef vector<vb> vvb;
template<typename T> using pq = priority_queue<T>; template<typename T> using mpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T> class infinity{ public: static constexpr T MAX=numeric_limits<T>::max(); static constexpr T MIN=numeric_limits<T>::min(); static constexpr T val=numeric_limits<T>::max()/2-1e6; static constexpr T mval=numeric_limits<T>::min()/2+1e6; };
const int INF = infinity<int>::val; const ll LINF = infinity<ll>::val; const ld DINF = infinity<ld>::val;
#define _overload5(a, b, c, d, e, name, ...) name
#define _overload4(a, b, c, d, name, ...) name
#define _overload3(a, b, c, name, ...) name
#define _rep0(n) for(ll i = 0; (ll)(i) < n; ++i)
#define _rep1(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define _rep2(i, a, b) for(ll i = (ll)(a); i < (ll)(b); ++i)
#define _rep3(i, a, b, c) for(ll i = (ll)(a); i < (ll)(b); i += (ll)(c))
#define rep(...) _overload4(__VA_ARGS__, _rep3, _rep2, _rep1, _rep0)(__VA_ARGS__)
#define _per0(n) for(ll i = 0; i < (ll)(n); ++i)
#define _per1(i, n) for(ll i = (ll)(n)-1; i >= 0; --i)
#define _per2(i, a, b) for(ll i = (ll)(b)-1; i >= (ll)(a); --i)
#define _per3(i, a, b, c) for(ll i = (ll)(b)-1; i >= (ll)(a); i -= (ll)(c))
#define rep_r(...) _overload4(__VA_ARGS__, _per3, _per2, _per1, _per0)(__VA_ARGS__)
#define _fore0(a) rep(a.size())
#define _fore1(i, a) for(auto &&i : a)
#define _fore2(a, b, v) for(auto &&[a, b] : v)
#define _fore3(a, b, c, v) for(auto &&[a, b, c] : v)
#define _fore4(a, b, c, d, v) for(auto &&[a, b, c, d] : v)
#define fore(...) _overload5(__VA_ARGS__, _fore4, _fore3, _fore2, _fore1, _fore0)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define rng_of(v, l, r) (v).begin() + l, (v).begin() + r
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define v3(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define v4(type, name, a, b, c, ...) vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

struct RandGen {
  using ud = uniform_int_distribution<ll>; mt19937 mt; RandGen() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}
  ll l(ll a, ll b) { ud d(a, b - 1); return d(mt); }
  LP lp(ll a, ll b, bool rng = true) { ll x = l(a, b - 1), y = l(rng ? x + 1 : a, b - 1); return {x, y}; }
  vl vecl(ll n, ll a, ll b) { ud d(a, b - 1); vl ret(n); rep(i, n) ret[i] = d(mt); return ret; }
  vl vecperm(ll n, ll from = 0) { vl perm(n); iota(all(perm), from); shuffle(perm); return perm; }
  string str(ll n, string op) { vl fig = vecl(n, 0, op.size()); string s; rep(i, n) s.pb(op[fig[i]]); return s; }
  string straz(ll n, ll a = 0, ll z = 26) { vl az = vecl(n, a, z); string s; rep(i, n) s.pb('a' + az[i]); return s; }
  string strnum(ll n, ll zero = 0, ll ten = 10) { vl zt = vecl(n, zero, ten); string s; rep(i, n) s.pb('0' + zt[i]); return s; }
  template<typename T> void shuffle(vector<T> &a) { std::shuffle(all(a), mt); }
};
// デバッグ系
#define dout cout
template<typename T, typename=void> struct is_specialize:false_type{};
template<typename T> struct is_specialize<T, typename conditional<false,typename T::iterator, void>::type>:true_type{};
template<typename T> struct is_specialize<T, typename conditional<false,decltype(T::first), void>::type>:true_type{};
template<typename T> struct is_specialize<T, enable_if_t<is_integral<T>::value, void>>:true_type{};
void dump(const char &t) { dout<<t; } void dump(const string &t) { dout<<t; } void dump(const bool &t) { dout<<(t ? "true" : "false"); }
template<typename T, enable_if_t<!is_specialize<T>::value, nullptr_t> =nullptr> void dump(const T&t) { dout << t; }
template<typename T> void dump(const T&t, enable_if_t<is_integral<T>::value>* =nullptr) { string tmp;if(t==infinity<T>::val||t==infinity<T>::MAX)tmp="inf";if(is_signed<T>::value&&(t==infinity<T>::mval||t==infinity<T>::MIN))tmp="-inf";if(tmp.empty())tmp=to_string(t);dout<<tmp; }
template<typename T, typename U, typename V> void dump(const tuple<T, U, V>&t) { dout<<"("; dump(get<0>(t)); dout<<" "; dump(get<1>(t)); dout << " "; dump(get<2>(t)); dout << ")"; }
template<typename T, typename U, typename V, typename S> void dump(const tuple<T, U, V, S>&t) { dout<<"("; dump(get<0>(t)); dout<<" "; dump(get<1>(t)); dout << " "; dump(get<2>(t)); dout << " "; dump(get<3>(t)); dout << ")"; }
template<typename T,typename U> void dump(const pair<T,U>&);
template<typename T> void dump(const T&t, enable_if_t<!is_void<typename T::iterator>::value>* =nullptr) { dout << "{ "; for(auto it=t.begin();it!=t.end();){ dump(*it); dout << (++it==t.end() ? "" : " "); } dout<<" }"; }
template<typename T,typename U> void dump(const pair<T,U>&t) { dout<<"("; dump(t.first); dout<<" "; dump(t.second); dout << ")"; }
void trace() { dout << "\n"; } template<typename Head, typename... Tail> void trace(Head&&head, Tail&&... tail) { dump(head); if(sizeof...(tail)) dout<<", "; trace(forward<Tail>(tail)...); }
#ifdef ONLINE_JUDGE
#define debug(...) (void(0))
#else
#define debug(...) do {dout<<#__VA_ARGS__<<" = ";trace(__VA_ARGS__); } while(0)
#endif
// 入出力系
#define LL(...) ll __VA_ARGS__; IN(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__; IN(__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__; IN(__VA_ARGS__)
#define _vl(name, size) vl name(size); IN(name)
#define _vl2(name, size, off) vl name(size); IN(name); rep(i, size) name[i]-=off
#define VL(...) _overload3(__VA_ARGS__, _vl2, _vl)(__VA_ARGS__)
#define VEC(type, name, size) vector<type> name(size); IN(name)
#define VEC2(type, name1, name2, size) vector<type> name1(size), name2(size); for(int i = 0; i < size; i++) IN(name1[i], name2[i])
#define VEC3(type, name1, name2, name3, size) vector<type> name1(size), name2(size), name3(size); for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i])
#define VEC4(type, name1, name2, name3, name4, size) vector<type> name1(size), name2(size), name3(size), name4(size); for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i], name4[i]);
#define VV(type, name, h, w) vector<vector<type>> name(h, vector<type>(w)); IN(name)
void scan(int &a) { cin >> a; } void scan(long long &a) { cin >> a; } void scan(char &a) { cin >> a; } void scan(double &a) { cin >> a; } void scan(string &a) { cin >> a; }
template <class T> void scan(T &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
void IN() {} template <class Head, class... Tail> void IN(Head &head, Tail &...tail) { scan(head); IN(tail...); }
#define OUTRET(...) { { OUT(__VA_ARGS__); return; } }
template <class T, class S> ostream &operator<<(ostream &os, const pair<T, S> &p) { return os << p.first << " " << p.second; }
void OUT() { cout << '\n'; } template <typename Head, typename... Tail> void OUT(const Head &head, const Tail &...tail) { cout << head; if(sizeof...(tail)) cout << ' '; OUT(tail...); }
template<class T, class S = ll> void OUTARRAY(vector<T>& v, S offset = S(0), string sep = " ") { rep(i, v.size()) { if (i > 0) cout << sep; if (offset != T(0)) { T t; t = v[i] + offset; cout << t; } else cout << v[i]; } cout << "\n"; }
template<class T, class S = ll> void OUTMAT(vector<vector<T>>& v, S offset = S(0)) { rep(i, v.size()) { OUTARRAY(v[i], offset); } }
template<typename T> void OUTBIN(T &a, int d) { for (int i = d - 1; i >= 0; i--) cout << ((a >> i) & (T)1); cout << "\n"; }
template<typename Q, typename A> void IQUERY(initializer_list<Q> q, A &a, string str = "? ") { cout << str; vector<Q> v(q); OUTARRAY(v); cout.flush(); cin >> a; }
// template<typename Q, typename A> void IQUERY(initializer_list<Q> q, A &a, string str = "? ") { vector<Q> query(q); RandGen rg;
//   a = query[0] ? A() : A();
// }
template<typename A> void IANSWER(initializer_list<A> a, string str = "! ") { cout << str; vector<A> v(a); OUTARRAY(v); cout.flush(); }
// 数値系
int ceil_pow2(ll n) { int x = 0; while ((1ULL << x) < (ull)(n)) x++; return x; }
int floor_pow2(ll n) { int x = 0; while ((1ULL << (x + 1)) <= (ull)(n)) x++; return x; }
pair<ll, ll> sqrtll(ll n) { ll x = round(sqrt(n)); if (x * x > n) --x; return {x, x + (x * x != n)}; }
ll POW(__uint128_t x, int n) { assert(n >= 0); ll res = 1; for(; n; n >>= 1, x *= x) if(n & 1) res *= x; return res; }
vl primes(const ll n) { vb isp(n + 1, true); for(ll i = 2; i * i <= n; i++) { if ((i > 2 && i % 2 == 0) || !isp[i]) continue; for(ll j = i * i; j <= n; j += i) isp[j] = 0; } vl ret; for(ll i = 2; i <= n; i++) if (isp[i]) ret.emplace_back(i); return ret; }
vl divisor(ll n) { vl ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.pb(i); if (i * i != n) ret.pb(n / i); } } sort(all(ret)); return ret; }
template<typename T> vl digits(T n) { assert(n >= 0); vl ret; while(n > 0) { ret.pb(n % 10); n /= 10; } return ret; }
template<class T, enable_if_t<is_integral<T>::value, nullptr_t> = nullptr> int msb(T x){ if (sizeof(x) == 4) return 31 - __builtin_clz(x); else return 63 - __builtin_clzll(x); }
template<class T, enable_if_t<is_integral<T>::value, nullptr_t> = nullptr> int lsb(T x){ if (sizeof(x) == 4) return __builtin_ctz(x); else return __builtin_ctzll(x); }
template<typename T, typename S> T ceil(T x, S y) { assert(y); return (y < 0 ? ceil(-x, -y) : (x > 0 ? (x + y - 1) / y : x / y)); }
template<typename T, typename S> T floor(T x, S y) { assert(y); return (y < 0 ? floor(-x, -y) : (x > 0 ? x / y : (x - y + 1) / y)); }
template<typename T = ll> T sum_of(const vector<T> &v, int l = 0, int r = INF) { return accumulate(rng_of(v, l, min(r, (int)v.size())), T(0)); }
ll max(int x, ll y) { return max((ll)x, y); } ll max(ll x, int y) { return max(x, (ll)y); }
ll min(int x, ll y) { return min((ll)x, y); } ll min(ll x, int y) { return min(x, (ll)y); }
ll mex(vl& v) { ll n = v.size(); vb S(n + 1); for (auto a: v) if (a <= n) S[a] = 1; ll ret = 0; while (S[ret]) ret++; return ret; }
// 操作系
template<class T> void rotate(vector<vector<T>> &a) { ll n = a.size(), m = a[0].size(); vector<vector<T>> ret(m, vector<T>(n, 0)); rep(i, n) rep(j, m) ret[j][n - 1 - i] = a[i][j]; a = ret; }
template<typename T> void uniq(vector<T>&a) { sort(all(a)); a.erase(unique(all(a)), a.end()); }
template<typename T> void comp(vector<T>&a) { vector<T> b = a; uniq(b); rep(i, a.size()) a[i] = lower_bound(all(b), a[i]) - b.begin(); }
template<class T = ll> pair<unordered_map<ll, ll>, unordered_map<ll, ll>> compmap(vector<T> &a) { vector<T> ca = a; comp(ca); unordered_map<ll, ll> ret, rev; rep(i, ca.size()) { ret[a[i]] = ca[i]; rev[ca[i]] = a[i]; } return mp(ret, rev); }
template<class T, class U> bool chmin(T &a, const U &b) { if (b < a) { a = b; return 1;} return 0; }
template<class T, class U> bool chmax(T &a, const U &b) { if (b > a) { a = b; return 1;} return 0; }
template<class T> int lbs(vector<T> &a, const T &b) { return lower_bound(all(a), b) - a.begin(); };
template<class T> int ubs(vector<T> &a, const T &b) { return upper_bound(all(a), b) - a.begin(); };
ll binary_search(function<bool(ll)> check, ll ok, ll ng, bool safe=true) { if (safe) { assert(check(ok)); assert(!check(ng)); } while (abs(ok - ng) > 1) { auto x = (ng + ok) / 2; if (check(x)) ok = x; else ng = x; } return ok; }
template<class T> vector<T> csum(vector<T> &a) { vl ret(a.size() + 1, 0); rep(i, a.size()) ret[i + 1] = ret[i] + a[i]; return ret; }
template<class S> vector<pair<S, int>> RLE(const vector<S> &v) { vector<pair<S, int>> res; for(auto &e : v) if(res.empty() or res.back().first != e) res.emplace_back(e, 1); else res.back().second++; return res; }
vector<pair<char, int>> RLE(const string &v) { vector<pair<char, int>> res; for(auto &e : v) if(res.empty() or res.back().first != e) res.emplace_back(e, 1); else res.back().second++; return res; }
template <class T, class S, class U> bool incl(const T &x, const S &l, const U &r) { return l <= x and x < r; }
void change_bit(ll &x, int b, int i) { assert(b < 63); if (!!(x & 1ll << b) ^ i) x ^= 1ll << b;  }
bool is_palindrome(string s) { rep(i, (s.size() + 1) / 2) if (s[i] != s[s.size() - 1 - i]) { return false; } return true; }
const string drul = "DRUL"; vl dx = {1, 0, -1, 0}; vl dy = {0, 1, 0, -1};

ll solve(ll n, vl a) {
  ll ans = n - a[0]; return ans;
}

ll naive(ll n, vl a) {
  ll ans = n + a[0]; return ans;
}

void compare(bool check = true) { RandGen rg; ll c = 0, loop = 10;
  while (++c) { if (c % loop == 0) cout << "reached " << c / loop << "loop" <<  "\n", cout.flush();
    ll n = 10;
    vl a = rg.vecl(n, 1, 1e2);
    auto so = solve(n, a); auto na = naive(n, a);
    if (!check || na != so) { cout << c << "times tried" << "\n";
      debug(n, a); debug(so); debug(na);
    if (check || (!check && c > loop)) break; }
  }
}

void solve() {
  LL(p1, t1, p2, t2, h, s);

  if (t1 == t2) OUTRET(ceil(h, p1 + p2 - s) * t1);
  if (t1 > t2) { swap(t1, t2); swap(p1, p2); }

  vv(ll, dp, h + 1, h + 10, LINF);
  dp[0][0] = 0;

  rep(i, h + 1) {
    rep(j, h + 1) {
      if (dp[i][j] == LINF) continue;
      // 1をもう一度うつ
      if (t1 * (j + 1) / t2 > t1 * j / t2) {
        chmin(dp[min(h, i + p1 + p2 - s * 2)][j + 1], dp[i][j] + t1);
      } else {
        chmin(dp[min(h, i + p1 - s)][j + 1], dp[i][j] + t1);
      }
      // 一緒に打つ
      ll off = ceil(t1 * (j + 1), t2) * t2 - t1 * j;
      chmin(dp[min(h, i + p1 + p2 - s)][0], dp[i][j] + off);
    }
  }
  // debug(dp);

  OUT(*min_element(all(dp[h])));
}

signed main() {
  cin.tie(0)->sync_with_stdio(0); cout.tie(0); cout << fixed << setprecision(20);
  int t = 1; //cin >> t;
  while (t--) solve();
  // while (t--) compare();
}

#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pb push_back
#define S second
#define F first
using namespace std;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll inf = 1e18;

int main()
{
    ios_base::sync_with_stdio(false);
    ll p1,p2,t1,t2,h,s;
    cin>>p1>>t1>>p2>>t2>>h>>s;

    vi dp(h+1,inf);
    dp[0]=0;

    if(t2<t1){
        swap(t1,t2);
        swap(p1,p2);
    }

    ll t = t2+t1-t2%t1;
    ll ex = (t2/t1)*(p1-s);
    ex +=(p1+p2-s);

    ll ex2 = (t2/t1-1)*(p1-s);
    ex2+=(p1+p2-s);
    ex2+=(p1+p2-s);
    for(ll i=0; i<=h; i++){
        if(dp[i]!=inf){

            for(ll j=t; ; j+=t1){
                ll x = (j/t1-1)*(p1-s)+(j/t2-1)*(p2-s)+(p2+p1-s);
                if(x+i>h) break;

                dp[i+x]=min(dp[i+x], dp[i]+j);
            }

            for(ll j=t2; ; j+=t2){
                ll x = (j/t1-1)*(p1-s)+(j/t2-1)*(p2-s)+(p2+p1-s);
                if(x+i>h) break;

                dp[i+x]=min(dp[i+x], dp[i]+j);
            }

        }
    }

    ll ans = inf;
    for(ll i=0; i<=h; i++){
        if(dp[i]==inf) continue;
        ll l=0; ll r=inf;
        ll curr = h-i;

        while(l<r){
            ll m = (l+r)/2;
            ll v = (m/t1)*(p1-s)+(m/t2)*(p2-s);

            if(v<curr){
                l=m+1;
            } else {
                r=m;
            }

        }
        ans=min(ans,l+dp[i]);

    }

    cout<<ans;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    cin.tie(0)->sync_with_stdio(0);
    ll p1, t1, p2, t2;
    cin >> p1 >> t1 >> p2 >> t2;
    ll h, s; cin >> h >> s;
    if (t1 > t2) swap(p1, p2), swap(t1, t2);

    auto solve = [&](auto self, ll h, ll c1) -> ll{
        if (h <= 0) return 0;
        ll ans = 1e18;
        ans = min(ans, (h+(p1-s)-1) / (p1-s) * t1 - c1);
        ans = min(ans, (h+(p2-s)-1) / (p2-s) * t2);
        // sync cannons, two cases
        // 1 waits for 2
        ll shots1 = (t2+c1)/t1 - 1;
        ll nh = h - (shots1 * (p1-s)) - (p1+p2-s);
        ans = min(ans, self(self, nh, 0) + t2);

        // 2 waits for 1
        ll t = (t2+c1)/t1 * t1;
        while (t < t2) t += t1;
        shots1 = (t + c1) / t1 - 1;
        nh = h - (shots1 * (p1-s)) - (p1+p2-s);
        ans = min(ans, self(self, nh, 0) + t);

        // not synced, skip to cannon 2 fires once
        shots1 = (t2+c1)/t1;
        ll nc1 = (t2+c1)%t1;
        nh = h - (shots1 * (p1-s)) - (p2-s);
        ans = min(ans, self(self, nh, nc1) + t2);

        return ans;
    };
    cout << solve(solve, h, 0) << '\n';
}

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

void solve()
{
	long long p1, t1, p2, t2, h, s;
	cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
	if(t1 < t2)
	{
		swap(p1, p2);
		swap(t1, t2);
	}
	long long ans = -1;
	long long k = t1 / t2;
	for(int i=0; i<=(h+p1-s-1)/(p1-s); i++)
		for(int j=0; j<=i; j++)
		{
			long long temp = (p1+p2-s) * j;
			temp += k*(p2-s)*j;
			long long tm = t1 * i;
			temp += (p1-s)*(i-j);
			if(temp >= h)
			{
				tm -= t1;
				if(ans != -1)
					ans = min(ans, tm);
				else
					ans = tm;
			}
			else
			{
				long long tt = h - temp;
				tm += (tt+p2-s-1)/(p2-s)*t2;
				tm -= t2;
				if(ans != -1)
					ans = min(ans, tm);
				else
					ans = tm;
			}
		}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(0);
	int t = 1;
	//cin >> t;
	while(t--) solve();
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
namespace fastIO{
	#define BUF_SIZE 100000
	#define OUT_SIZE 100000
	//fread->read
	bool IOerror=0;
	//inline char nc(){char ch=getchar();if(ch==-1)IOerror=1;return ch;}
	inline char nc(){
		static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
		if(p1==pend){
			p1=buf;pend=buf+fread(buf,1,BUF_SIZE,stdin);
			if(pend==p1){IOerror=1;return -1;}
		}
		return *p1++;
	}
	inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
	template<class T> inline bool read(T &x){
		bool sign=0;char ch=nc();x=0;
		for(;blank(ch);ch=nc());
		if(IOerror)return false;
		if(ch=='-')sign=1,ch=nc();
		for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
		if(sign)x=-x;
		return true;
	}
	inline bool read(double &x){
		bool sign=0;char ch=nc();x=0;
		for(;blank(ch);ch=nc());
		if(IOerror)return false;
		if(ch=='-')sign=1,ch=nc();
		for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
		if(ch=='.'){
			double tmp=1; ch=nc();
			for(;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0');
		}
		if(sign)x=-x;
		return true;
	}
	inline bool read(char *s){
		char ch=nc();
		for(;blank(ch);ch=nc());
		if(IOerror)return false;
		for(;!blank(ch)&&!IOerror;ch=nc())*s++=ch;
		*s=0;
		return true;
	}
	inline bool read_line(char *s){
		char ch=nc();
		for(;blank(ch);ch=nc());
		if(IOerror)return false;
		for(;ch!='\n'&&!IOerror;ch=nc())*s++=ch;
		*s=0;
		return true;
	}
	inline bool read(char &c){
		for(c=nc();blank(c);c=nc());
		if(IOerror){c=-1;return false;}
		return true;
	}
	template<class T,class... U>bool read(T& h,U&... t){return read(h)&&read(t...);}
	#undef OUT_SIZE
	#undef BUF_SIZE
};
using namespace fastIO;
/************* debug begin *************/
string to_string(string s){return '"'+s+'"';}
string to_string(const char* s){return to_string((string)s);}
string to_string(const bool& b){return(b?"true":"false");}
template<class T>string to_string(T x){ostringstream sout;sout<<x;return sout.str();}
template<class A,class B>string to_string(pair<A,B> p){return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template<class A>string to_string(const vector<A> v){
	int f=1;string res="{";for(const auto x:v){if(!f)res+= ", ";f=0;res+=to_string(x);}res+="}";
	return res;
}
void debug_out(){puts("");}
template<class T,class... U>void debug_out(const T& h,const U&... t){cout<<" "<<to_string(h);debug_out(t...);}
#ifdef tokitsukaze
#define debug(...) cout<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__);
#else
#define debug(...) 233;
#endif
/*************  debug end  *************/
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define sqr(x) (x)*(x)
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<int,ll> PIL;
typedef pair<ll,int> PLI;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<PII > VPII;
/************* define end  *************/
void read(int *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);}
void read(ll *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);}
void read(double *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);}
void println(VI x){for(int i=0;i<sz(x);i++) printf("%d%c",x[i]," \n"[i==sz(x)-1]);}
void println(VL x){for(int i=0;i<sz(x);i++) printf("%lld%c",x[i]," \n"[i==sz(x)-1]);}
void println(int *x,int l,int r){for(int i=l;i<=r;i++) printf("%d%c",x[i]," \n"[i==r]);}
void println(ll *x,int l,int r){for(int i=l;i<=r;i++) printf("%lld%c",x[i]," \n"[i==r]);}
/*************** IO end  ***************/
void assert_lr(ll x,ll l,ll r) {assert(x>=l&&x<=r);};
void go();
int main(){
	#ifdef tokitsukaze
		freopen("TEST.txt","r",stdin);
	#endif
	go();return 0;
}
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const double eps=1e-6;
const int MAX=1e6+10;
const ll mod=1e9+7;
/*********************************  head  *********************************/
ll dp[20050];
void go()
{
	int p1,p2,h,s,i,j,tmp;
	ll t1,t2,cnt,ans;
	tmp=10000;
	while(read(p1,t1))
	{
		read(p2,t2);
		read(h,s);
		h+=tmp;
		mem(dp,0x3f);
		dp[h]=0;
		for(i=h-1;~i;i--)
		{
			for(j=1;;j++)
			{
				cnt=j*t1/t2;
				if(i+(p1-s)*j+(p2-s)*cnt>h) break;
				dp[i]=min(dp[i],dp[i+(p1-s)*j+(p2-s)*cnt]+max(t1*j,t2*cnt));
			}
			for(j=1;;j++)
			{
				cnt=j*t2/t1;
				if(i+(p1-s)*cnt+(p2-s)*j>h) break;
				dp[i]=min(dp[i],dp[i+(p1-s)*cnt+(p2-s)*j]+max(t1*cnt,t2*j));
			}
			for(j=1;;j++)
			{
				if(i+(p1+p2-s)*j>h) break;
				dp[i]=min(dp[i],dp[i+(p1+p2-s)*j]+max(t1,t2)*j);
			}
		}
		ans=LLINF;
		for(i=tmp;~i;i--) ans=min(ans,dp[i]);
		printf("%lld\n",ans);
	}
}

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> PII;
typedef std::pair<ll, ll> PLL;
typedef double db;
#define re _read
#define ALL(x) (x).begin(),(x).end()
#define SZ(v) ((int)v.size())
#define fi first
#define se second
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl "\n"
using namespace std;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x;}
template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) { out << "["; bool first = true; for (auto &&e : v) { if (first) { first = false;} else {out << ", ";} out << e; } return out << "]"; }
template <typename A, typename B> std::ostream &operator<<(std::ostream &out, const std::pair<A, B> &v) {  return out << "(" << v.first << ", " << v.second << ")"; }
template <typename K> std::ostream &operator<<(std::ostream &out, const std::set<K> &s) {  out << "{"; bool first = true; for (auto &&k : s) { if (first) { first = false; } else { out << ", "; } out << k; } return out << "}"; }
template <typename K, typename V> std::ostream &operator<<(std::ostream &out, const std::map<K, V> &m) { out << "{"; bool first = true; for (auto &&[k, v] : m) { if (first) { first = false; } else { out << ", "; } out << k << ": " << v; } return out << "}"; }
template <class T> vector<vector<T>> Vector(int n, int m) { return vector<vector<T>> (n, vector<T> (m, 0)); }
template <class T> vector<vector<vector<T>>> Vector(int i, int j, int k) { return vector<vector<vector<T>>> (i, vector<vector<T>>(j, vector<T>(k, 0))); }
template <typename T> void OUT(T* a, int l, int r) { for (int i = l; i <= r; i ++) cout << a[i] << " "; puts(""); }
template<class T>
inline void _read(T& x) {
    static T ans;
    static unsigned int c;
    static bool p;
    for (c = getchar(); c != '-' && (c < '0' || c > '9'); c = getchar());
    if (c == '-') p = false, c = getchar(); else p = true;
    for (ans = 0; c <= '9' && c >= '0'; c = getchar()) ans = ans * 10 + c - '0';
    x = p ? ans : -ans;
}
/*----------------------------------------------------------------------------------------------------*/
const int N = 2510 * 2510;
ll dp[N], p1, t1, p2, t2, h, s, mx[N];
vector<ll> alls;

int find(int x) {
    return lower_bound(ALL(alls), x) - alls.begin();
}

int get(int x) {
    return upper_bound(ALL(alls), x) - alls.begin() - 1;
}

int main() {
    // freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
    int T;
    re(p1), re(t1), re(p2), re(t2);
    re(h), re(s);
    alls.pb(0);
    for (int i = 0; i <= 2505 ; i++) {
        for (int j = 0; j <= 2505; j++) {
            // printf("i=%d, j=%d\n",i,j);
            alls.pb(i * t1 + j * t2);
        }
    }
    sort(ALL(alls));
    alls.erase(unique(ALL(alls)), alls.end());
    int n = SZ(alls);
    memset(dp, -0x3f, sizeof dp);
    dp[0] = 0;
    for (int i = 1; i <= n - 1; i++) {
        int l1 = get(alls[i] - t1), l2 = get(alls[i] - t2), l12 = get(alls[i] - max(t1, t2));
        if (l1 >= 0 && alls[i] - alls[l1] >= t1)
            dp[i] = max(dp[i], mx[l1] + p1 - s);
        if (l2 >= 0 && alls[i] - alls[l2] >= t2)
            dp[i] = max(dp[i], mx[l2] + p2 - s);
        if (l12 >= 0 && alls[i] - alls[l12] >= max(t1, t2))
            dp[i] = max(dp[i], mx[l12] + p1 + p2 - s);
        mx[i] = max(dp[i], mx[i - 1]);
        // printf("dp[%d]=%lld\n", i, dp[i]);
        if (dp[i] >= h) {
            printf("%lld\n", alls[i]);
            return 0;
        }
    }
    // fclose(stdin);
    // fclose(stdout);
    return 0;
}

#include<bits/stdc++.h>
#define fep(i,l,r) for(int i=l;i<=r;++i)
#define feb(i,r,l) for(int i=r;i>=l;--i)
#define For(i,u) for(int i=head[u];i;i=e[i].nxt)
#define int long long
#define LL long long
#define mpr make_pair
#define pr pair<int,int>
#define mpr make_pair
using namespace std;

const int N = 5000+5,M = 105,K = 17,INF = 1e9;
int p1,t1,p2,t2,h,s,f[N],ans=1e18;

inline int read()
{
	int s=0,w=1; char ch=getchar();
	while(!(ch>='0'&&ch<='9')) {if(ch=='-') w=-1; ch=getchar();}
	while(  ch>='0'&&ch<='9')  {s=(s<<1)+(s<<3)+ch-'0'; ch=getchar();}
	return s*w;
}

inline void solve(int i)
{
	fep(j,1,h)
	{
		int t=j*t1,tmp=(t-1)/t2-1;
		if(t<t2) continue;
		int res=i-(p1+p2-s)-(j-1)*max(0ll,p1-s)-tmp*max(0ll,p2-s);
		if(res<=0) ans=min(ans,f[i]+t);
		else f[res]=min(f[res],f[i]+t);
	}
}

signed main()
{
	p1=read(),t1=read(),p2=read(),t2=read(),h=read(),s=read();
	if(max(p1,p2)<=s)
	{
		int tmp=(h-1)/(p1+p2-s)+1;
		printf("%lld",tmp*max(t1,t2));
		return 0;
	}
	if(p1>s) ans=min(ans,((h-1)/(p1-s)+1)*t1);
	if(p2>s) ans=min(ans,((h-1)/(p2-s)+1)*t2);
	memset(f,0x3f,sizeof(f));
	f[h]=0;
	feb(i,h,1)
	{
		solve(i);
		swap(p1,p2); swap(t1,t2);
		solve(i);
	}
	printf("%lld",ans);
	return 0;
}

/*
DavitMarg
In a honky-tonk,
Down in Mexico
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <random>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#define mod 998244353ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v,l,r) v.begin(), v.end()
#define fastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

const int N = 5005;

LL p1, p2, t1, t2, h, s;
LL dp[N][N];

void solve()
{
	cin >> p1 >> t1;
	cin >> p2 >> t2;
	cin >> h >> s;

	if (t1 > t2)
	{
		swap(p1, p2);
		swap(t1, t2);
	}

	for (int i = h; i >= 0; i--)
		for (int j = 0; j <= h / (p1 - s) + 1; j++)
			dp[i][j] = mod * mod;

	dp[h][0] = 0;
	for (int i = h; i >= 1; i--)
	{
		for (int j = 0; j <= h / (p1 - s) + 1; j++)
		{
			dp[max(0ll, i - (p1 - s))][j + 1] = min(dp[max(0ll, i - (p1 - s))][j + 1], dp[i][j] + t1);

			if (t1 * j <= t2)
				dp[max(0ll, i - (p1 + p2 - s))][0] = min(dp[max(0ll, i - (p1 + p2 - s))][0], dp[i][j] + t2 - j * t1);
			else
				dp[max(0ll, i - (p1 + p2 * ((t1 * j)/t2) - s))][0] = min(dp[max(0ll, i - (p1 + p2 * ((t1 * j) / t2) - s))][0], dp[i][j]);
		}
	}

	LL ans = mod * mod;

	for (int j = 0; j <= h / (p1 - s) + 1; j++)
		ans = min(ans, dp[0][j]);

	cout << ans << endl;

}

int main()
{
	fastIO;
	int T = 1;
	//cin >> T;
	while (T--)
		solve();
	return 0;
}

/*

4 9
5 10
16 1

cd /mnt/d/Davit/ProgProjects/DavitMargCP/DavitMargCP; g++ -std=c++17 -O2 -Wall -Wextra -Ddeath -Wshadow src.cpp -o orz; ./orz; rm orz

*/

#include <bits/stdc++.h>

#define int long long

using namespace std;

typedef long long ll;
typedef long double ld;

#define pii pair<int, int>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

int32_t main() {
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int p1, t1, p2, t2, h, s;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

    set<int> t;

    for (int i = 1; i <= h; i++) {
        t.insert(t1 * i);
        t.insert(t2 * i);
    }

    vector<int> dp(h + 1, LLONG_MAX);
    dp[0] = 0;

    for (int i = 1; i <= h; i++) {
        for (int x : t) {
            if (x >= max(t1, t2)) {
                int damage = x / t1 * (p1 - s) + x / t2 * (p2 - s) + s;
                if (damage <= i) {
                    if (dp[i - damage] < LLONG_MAX) {
                        dp[i] = min(dp[i], dp[i - damage] + x);
                    }
                }
            }
        }
    }

    vector<int> d(h + 1, LLONG_MAX);
    d[0] = 0;

    for (int x : t) {
        int damage = x / t1 * (p1 - s) + x / t2 * (p2 - s);
        d[min(h, damage)] = min(d[min(h, damage)], x);
    }
    for (int i = h - 1; i >= 1; i--) {
        d[i] = min(d[i], d[i + 1]);
    }

    int ans = LLONG_MAX;

    for (int i = 0; i <= h; i++) {
        if (dp[i] < LLONG_MAX && d[h - i] < LLONG_MAX) {
            ans = min(ans, dp[i] + d[h - i]);
        }
    }

    cout << ans;

    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define uint unsigned long long

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
const int N = 6000;
const int INF = 2e18;
const int M = 998244353;
const ld EPS = 1e-6;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt = 1;
    while (tt--) {
        int p1, t1;
        int p2, t2;
        cin >> p1 >> t1;
        cin >> p2 >> t2;
        if (t1 > t2) {
            swap(t1,t2);
            swap(p1,p2);
        }
        int h,s;
        cin >> h >> s;
        vector<int> dp(h + 1, INF);
        dp[0] = 0;
        int ans = INF;
        vector<int> muls;
        for (int i = 1; i <= N; ++i) {
            if (to_string(i).size() + to_string(t1).size() > 17) break;
            muls.push_back(i * t1);
            muls.push_back(i * t2);
        }
        sort(all(muls));
        for (int d = 0; d <= h; ++d) {
            for (auto t : muls) {
                int col1 = t / t1 - 1;
                int col2 = t / t2 - 1;
                if (col2 < 0) {
                    int D = (col1 + 1) * (p1 - s);
                    if (D >= h) {
                        ans = min(ans, dp[d] + t);
                    }
                } else {
                    int D = col1 * (p1 - s) + col2 * (p1 - s) + (p1 + p2 - s);
                    if (d + D >= h) {
                        ans = min(ans, dp[d] + t);
                    } else {
                        dp[D + d] = min(dp[D + d], dp[d] + t) ;
                    }
                }

            }
        }
        cout << min(ans, dp[h]) << endl;

    }
}
// 00000000101
// we cant remove 1
// we cant concat 1
// we can move 1
// we can add 1 near 1
//01111100000
//12383305831528
//19563725075771

//1110010

#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 924844033

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define getrand(l, r) uniform_int_distribution<int>(l, r)(rng)

long long t1 , t2;

int s , p1 , p2;

int h;

const int N = 5010;
long long mn[N];

int main(){
	cin >> p1 >> t1;
	cin >> p2 >> t2;
	cin >> h >> s;

	for(int i = 1;i <= h;i++)
		mn[i] = (long long)1e18;

	for(int take = 1;take <= h;take++){
		long long last = (long long)take * t1;
		if(last < t2) continue;
		long long take2 = last / t2;
		long long cur = (take - 1) * (p1 - s) + (take2 - 1) * (p2 - s) + (p1 + p2 - s);

		if(cur >= (long long)h)
			cur = h;
		mn[cur] = min(mn[cur] , last);
	}

	for(int take2 = 1;take2 <= h;take2++){
		long long last = (long long)take2 * t1;
		if(last < t2) continue;
		long long take = last / t1;

		long long cur = (take - 1) * (p1 - s) + (take2 - 1) * (p2 - s) + (p1 + p2 - s);

		if(cur >= (long long)h)
			cur = h;
		mn[cur] = min(mn[cur] , last);
	}

	long long ans = min(t1 * ((h + (p1 - s) - 1) / (p1 - s) ), t2 * ((h + (p2 - s) - 1) / (p2 - s)));

	for(int i = 1;i <= h;i++){
		for(int j = 1;j < i;j++){
			mn[i] = min(mn[i] , mn[j] + mn[i - j]);
		}
	}

	ans = min(ans , mn[h]);
	cout << ans << endl;

	return 0;
}

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

void test_case()
{
    array<int64_t, 2> p, t;
    int64_t h, s;
    cin >> p[0] >> t[0] >> p[1] >> t[1] >> h >> s;

    if (t[0] < t[1]) {
        swap(t[0], t[1]);
        swap(p[0], p[1]);
    }

    vector<int64_t> ans(h + 1, numeric_limits<int64_t>::max());
    ans[0] = 0;
    for (int H = 1; H <= h; ++H) {
        for (int j = 0; j < 2; ++j) {
            int cnt = 1;
            for (int64_t T = (t[j ^ 1] + t[j] - 1) / t[j] * t[j]; T < ans[H];
                 T += t[j]) {
                int cur = H;
                for (int i = 0; i < 2; ++i)
                    cur -= (T / t[i]) * (p[i] - s);
                cur -= cnt * s;

                if (cur < 0)
                    ans[H] = min(ans[H], T);
                else
                    ans[H] = min(ans[H], ans[cur] + T);

                if (T % t[j ^ 1] == 0)
                    ++cnt;
            }
        }
    }

    cout << ans[h] << '\n';
}

int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int Case = 1;
    // cin >> Case;
    for (int i = 1; i <= Case; i++) {
        // cout << "Case #" << i << ": ";
        test_case();
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

void solve() {
	ll p1, t1, p2, t2, h, s;
	cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
	if (t1 > t2) {
		swap(t1, t2);
		swap(p1, p2);
	}
	// t1 is shorter

	vector<ll> dp(h+1, 4e18);
	dp[0] = 0;
	for (int i=0; i<h; ++i) {
		dp[min(h, (t2/t1)*(p1-s)+p1+p2-s+i)] = min(dp[min(h, (t2/t1)*(p1-s)+p1+p2-s+i)], dp[i] + (t2/t1+1)*t1);
		dp[min(h, (t2/t1-1)*(p1-s)+p1+p2-s+i)] = min(dp[min(h, (t2/t1-1)*(p1-s)+p1+p2-s+i)], dp[i] + t2);
	}

	ll ans = 9e18;
	for (int i=0; i<=h; ++i) {
		ll lo = -1, hi = 1e18;
		while (lo + 1 < hi) {
			const ll mid = (lo + hi) / 2;
			if ((__int128)mid/t1*(p1-s) + (__int128)mid/t2*(p2-s) < h-i)
				lo = mid;
			else
				hi = mid;
		}
		ans = min(ans, dp[i] + hi);
	}
	cout << ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
//	int t; cin >> t;
//	while (t--)
		solve();
	return 0;
}

// Problem: E. FTL
// URL: https://codeforces.com/contest/1743/problem/E
// Group: Codeforces - Educational Codeforces Round 137 (Rated for Div. 2)
// Time: 2022-10-17 22:35
// Author: lingfunny

#include <bits/stdc++.h>
#define LL long long
using namespace std;

const int mxn = 1e4 + 10;
const LL inf = 1e18;

int p1, p2, h, s;
LL t1, t2, f[mxn];
// 0 represent used

signed main() {
	scanf("%d%lld%d%lld%d%d", &p1, &t1, &p2, &t2, &h, &s);
	// if (p1 <= s || p2 <= s) return !printf("%lld\n", (h + (p1 + p2 - s) - 1) / (p1 + p2 - s) * max(t1, t2));
	for (int i = 1; i <= h; ++i) f[i] = inf;
	f[0] = 0;
	LL t = 0, cd1 = t1, cd2 = t2;
	int tot = 0;
	while (tot <= h) {
		LL cd = min(cd1, cd2);
		t += cd;
		cd1 -= cd, cd2 -= cd;
		if (!cd1 && !cd2) tot += p1 + p2 - s, cd1 = t1, cd2 = t2;
		else if (!cd1) tot += p1 - s, cd1 = t1;
		else if (!cd2) tot += p2 - s, cd2 = t2;
		f[min(tot, h)] = min(f[min(tot, h)], t);
		// printf("t = %lld, tot = %d\n", t, tot);
	}
	for (int i = h - 1; ~i; --i) f[i] = min(f[i + 1], f[i]);
	for (int i = 0; i <= h; ++i)
		for (int j = 0; j <= i; ++j) f[i] = min(f[i], f[j] + f[i - j]);
	LL ans = inf;
	for (int i = 0; i <= h; ++i) ans = min(ans, f[max(0, h - i * (p1 + p2 - s))] + i * max(t1, t2));
	printf("%lld\n", ans);
	return 0;
}

#include<bits/stdc++.h>
#define prob "E"
using namespace std;
const int maxn = 1e5;
const int MOD = 1e9 + 7;
const long long INF = 1e18;
/*
    dp[i] is the minimal time to kill monster with durability i
    dp[i] = min(
        dp[i-p1+s] + t1, if used laser 1
        dp[i-p2+s] + t2, if used laser 2

                )
*/
int main(){
//    freopen(prob".inp","r",stdin);
//    freopen(prob".out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    long long p1,p2,t1,t2;
    int h;
    long long s;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
    vector<long long> dp(h+1,INF);
    dp[0] = 0ll;
    for(int i=1;i<=h;i++){
        dp[i] = min(dp[max(0ll,i-p1+s)]+t1,dp[max(0ll,i-p2+s)]+t2);
        for(int type=0;type<=1;type++){
            for(int time_use=1;time_use<=i;time_use++){
                long long t = 1ll * time_use * t1;
                long long dam = 1ll * time_use * (p1 - s);
                /// We can use laser 2 during using laser 1

                long long time_using_laser_2 = t / t2;
                if(time_using_laser_2){
                    /*
                        t1 2*t1 ... time_use*t1
                        3 6 9 12 15 t1 = 3, time_use = 5
                          x    x    t2 = 4,
                        3 6 9 12 15 t1 = 3, time_use = 5
                        x x x x  x  t2 = 3
                    */
                    if(t1 != t2) dam += p2 * (time_using_laser_2 - 1);
                    else dam += p2 * (time_using_laser_2 - 1);
                }
                dp[i] = min(dp[i],dp[max(0ll,i-dam)]+t);
            }
            swap(p1,p2);
            swap(t1,t2);
        }
    }
    cout << dp[h];
}

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

#define CONSTANTS
// #define CAST_MINT_TO_LL
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

constexpr long long INF = 1e18;
// constexpr long long INF = LONG_LONG_MAX;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr long double EPS = 1e-10;
constexpr long double PI = M_PI;

using ll = long long; using ull = unsigned long long; using ld = long double; using pll = pair<ll, ll>; using pii = pair<int, int>; using pli = pair<ll, int>; using pil = pair<int, ll>; using vvl = vector<vector<ll>>; using vvi = vector<vector<int>>; using vvpll = vector<vector<pll>>; using vvpli = vector<vector<pli>>; using vvpil = vector<vector<pil>>;
#define name4(i, a, b, c, d, e, ...) e
#define rep(...) name4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(i, a) for (ll i = 0, _aa = a; i < _aa; i++)
#define rep2(i, a, b) for (ll i = a, _bb = b; i < _bb; i++)
#define rep3(i, a, b, c) for (ll i = a, _bb = b; (c > 0 && a <= i && i < _bb) or (c < 0 && a >= i && i > _bb); i += c)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define ALL(A) A.begin(), A.end()
#define UNIQUE(A) sort(ALL(A)), A.erase(unique(ALL(A)), A.end())
#define elif else if
#define tostr to_string
#ifndef CONSTANTS
constexpr ll INF = 1e18; constexpr int MOD = 1000000007; constexpr ld EPS = 1e-10; constexpr ld PI = M_PI;
#endif
template<int mod> struct ModInt { int x = 0; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator++() { x++; if (x == mod) x = 0; return *this; } ModInt &operator--() { if (x == 0) x = mod; x--; return *this; } ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int) (1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inv(); return *this; } ModInt operator++(int) { ModInt result = *this; ++*this; return result; } ModInt operator--(int) { ModInt result = *this; --*this; return result; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inv() const { int a = x, b = mod, u = 1, v = 0, t; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while(n > 0) { if(n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); } static int get_mod() { return mod; }
#ifdef CAST_MINT_TO_LL
operator ll() const { return x; }
#endif
};
using mint = ModInt<MOD>;
template<typename T> vector<vector<T>> list2d(int N, int M, T init) { return vector<vector<T>>(N, vector<T>(M, init)); } template<typename T> vector<vector<vector<T>>> list3d(int N, int M, int L, T init) { return vector<vector<vector<T>>>(N, vector<vector<T>>(M, vector<T>(L, init))); } template<typename T> vector<vector<vector<vector<T>>>> list4d(int N, int M, int L, int O, T init) { return vector<vector<vector<vector<T>>>>(N, vector<vector<vector<T>>>(M, vector<vector<T>>(L, vector<T>(O, init)))); } template<typename T> vector<T> listnd(size_t a, T b) { return vector<T>(a, b); } template<typename... Ts> auto listnd(size_t a, Ts... ts) { return vector<decltype(listnd(ts...))>(a, listnd(ts...)); }
template<typename T=ll> vector<T> LIST(ll N) { vector<T> A(N); rep(i, N) { cin >> A[i]; } return A; } template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in: v) is >> in; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second; } template<typename T1, typename T2, typename T3> ostream &operator<<(ostream &os, const tuple<T1, T2, T3> &tp) { return os << get<0>(tp) << ' ' << get<1>(tp) << ' ' << get<2>(tp); } template<typename T1, typename T2, typename T3, typename T4> ostream &operator<<(ostream &os, const tuple<T1, T2, T3, T4> &tp) { return os << get<0>(tp) << ' ' << get<1>(tp) << ' ' << get<2>(tp) << ' ' << get<3>(tp); } template<typename T, size_t SZ> ostream &operator<<(ostream &os, const array<T, SZ> &arr) { rep(i, arr.size()) { os << arr[i]; if (i != (ll)arr.size()-1) { os << ' '; } } return os; } template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { rep(i, vec.size()) { os << vec[i]; if (i != (ll)vec.size()-1) { os << ' '; } } return os; } void print() { cout << '\n'; } template<typename T> void print(T out) { cout << out << '\n'; } template<typename T1, typename T2, typename T3> void print(const tuple<T1, T2, T3> &tp) { cout << get<0>(tp) << ' ' << get<1>(tp) << ' ' << get<2>(tp) << '\n'; } template<typename T1, typename T2, typename T3, typename T4> void print(const tuple<T1, T2, T3, T4> &tp) { cout << get<0>(tp) << ' ' << get<1>(tp) << ' ' << get<2>(tp) << ' ' << get<3>(tp) << '\n'; } template<typename T> void print(const vector<T> &V, char sep=' ') { rep(i, V.size()) { cout << V[i]; if (i != (ll)V.size()-1) cout << sep; } cout << '\n'; } template<typename T, size_t SZ> void print(const array<T, SZ> &arr, char sep=' ') { rep(i, arr.size()) { cout << arr[i]; if (i != (ll)arr.size()-1) cout << sep; } cout << '\n'; } template<typename T> void print(const deque<T> &que) { vector<T> V(ALL(que)); print(V); } template<typename T> void print(const set<T> &se) { vector<T> V(ALL(se)); print(V); }
#define debug(x) (cout << #x << ": ", print(x));
void Yes() { print("Yes"); } void No() { print("No"); } void YES() { print("YES"); } void NO() { print("NO"); }
ll toint(string s) { assert(s.size() < 20); ll res = 0; for (char &c : s) { res *= 10; res += c - '0'; } return res; } int toint(char num) { return num - '0'; }
char tochar(int num) { return '0' + num; }
template<typename T> T ceil(T a, T b) { if (a >= 0) return (a+b-1) / b; else return a / b; }
template<typename T> T modulo(T a, T b) { return ((a % b) + b) % b; }
template<typename T> pair<T, T> divmod(T a, T b) { T d = a / b; T m = a % b; return {d, m}; }
template<typename T> bool chmin(T &x, T y) { return (y < x) ? x = y, true : false; }
template<typename T> bool chmax(T &x, T y) { return (y > x) ? x = y, true : false; }
template<typename T> T sum(const vector<T> &A) { return accumulate(ALL(A), (T)0); } template<typename key, typename val> val sum(const map<key, val> &mp) { val res = 0; for (auto& [k, v] : mp) res += v; return res; }
template<typename T> T min(const vector<T> &A) { return *min_element(ALL(A)); } template<typename key, typename val> val min(const map<key, val> &mp) { val res = numeric_limits<val>::max(); for (auto& [k, v] : mp) chmin(res, v); return res; }
template<typename T> T max(const vector<T> &A) { return *max_element(ALL(A)); } template<typename key, typename val> val max(const map<key, val> &mp) { val res = numeric_limits<val>::min(); for (auto& [k, v] : mp) chmax(res, v); return res; }
ll pow(ll x, ll n) { ll res = 1; rep(_, n) res *= x; return res; } ll pow(int x, ll n) { return pow((ll)x, n); } ll pow(ll x, int n) { return pow(x, (ll)n); } ll pow(int x, int n) { return pow((ll)x, (ll)n); } ll pow(ll x, ll n, int mod) { x %= mod; ll res = 1; while (n > 0) { if (n & 1) { res = (res * x) % mod; } x = (x * x) % mod; n >>= 1; } return res; }
int popcount(ll S) { return __builtin_popcountll(S); }
int bit_length(ll x) { int res = 0; while (x) { res++; x /= 2; } return res; }
template<typename T> int bisect_left(const vector<T> &A, T val, int lo=0) { return lower_bound(A.begin()+lo, A.end(), val) - A.begin(); } template<typename T> int bisect_right(const vector<T> &A, T val, int lo=0) { return upper_bound(A.begin()+lo, A.end(), val) - A.begin(); }
namespace HashMapImpl { using u32 = uint32_t; using u64 = uint64_t; template <typename Key, typename Data> struct HashMapBase; template <typename Key, typename Data> struct itrB : iterator<bidirectional_iterator_tag, Data, ptrdiff_t, Data*, Data&> { using base = iterator<bidirectional_iterator_tag, Data, ptrdiff_t, Data*, Data&>; using ptr = typename base::pointer; using ref = typename base::reference; u32 i; HashMapBase<Key, Data>* p; explicit constexpr itrB() : i(0), p(nullptr) {} explicit constexpr itrB(u32 _i, HashMapBase<Key, Data>* _p) : i(_i), p(_p) {} explicit constexpr itrB(u32 _i, const HashMapBase<Key, Data>* _p) : i(_i), p(const_cast<HashMapBase<Key, Data>*>(_p)) {} friend void swap(itrB& l, itrB& r) { swap(l.i, r.i), swap(l.p, r.p); } friend bool operator==(const itrB& l, const itrB& r) { return l.i == r.i; } friend bool operator!=(const itrB& l, const itrB& r) { return l.i != r.i; } const ref operator*() const { return const_cast<const HashMapBase<Key, Data>*>(p)->data[i]; } ref operator*() { return p->data[i]; } ptr operator->() const { return &(p->data[i]); } itrB& operator++() { assert(i != p->cap && "itr::operator++()"); do { i++; if (i == p->cap) break; if (p->flag[i] == true && p->dflag[i] == false) break; } while (true); return (*this); } itrB operator++(int) { itrB it(*this); ++(*this); return it; } itrB& operator--() { do { i--; if (p->flag[i] == true && p->dflag[i] == false) break; assert(i != 0 && "itr::operator--()"); } while (true); return (*this); } itrB operator--(int) { itrB it(*this); --(*this); return it; } }; template <typename Key, typename Data> struct HashMapBase { using u32 = uint32_t; using u64 = uint64_t; using iterator = itrB<Key, Data>; using itr = iterator; protected: template <typename K> inline u64 randomized(const K& key) const { return u64(key) ^ r; } template <typename K, enable_if_t<is_same<K, Key>::value, nullptr_t> = nullptr, enable_if_t<is_integral<K>::value, nullptr_t> = nullptr> inline u32 inner_hash(const K& key) const { return (randomized(key) * 11995408973635179863ULL) >> shift; } template < typename K, enable_if_t<is_same<K, Key>::value, nullptr_t> = nullptr, enable_if_t<is_integral<decltype(K::first)>::value, nullptr_t> = nullptr, enable_if_t<is_integral<decltype(K::second)>::value, nullptr_t> = nullptr> inline u32 inner_hash(const K& key) const { u64 a = randomized(key.first), b = randomized(key.second); a *= 11995408973635179863ULL; b *= 10150724397891781847ULL; return (a + b) >> shift; } template <typename K, enable_if_t<is_same<K, Key>::value, nullptr_t> = nullptr, enable_if_t<is_integral<typename K::value_type>::value, nullptr_t> = nullptr> inline u32 inner_hash(const K& key) const { static constexpr u64 mod = (1LL << 61) - 1; static constexpr u64 base = 950699498548472943ULL; u64 res = 0; for (auto& elem : key) { __uint128_t x = __uint128_t(res) * base + (randomized(elem) & mod); res = (x & mod) + (x >> 61); } __uint128_t x = __uint128_t(res) * base; res = (x & mod) + (x >> 61); if (res >= mod) res -= mod; return res >> (shift - 3); } template <typename D = Data, enable_if_t<is_same<D, Key>::value, nullptr_t> = nullptr> inline u32 hash(const D& dat) const { return inner_hash(dat); } template < typename D = Data, enable_if_t<is_same<decltype(D::first), Key>::value, nullptr_t> = nullptr> inline u32 hash(const D& dat) const { return inner_hash(dat.first); } template <typename D = Data, enable_if_t<is_same<D, Key>::value, nullptr_t> = nullptr> inline Key dtok(const D& dat) const { return dat; } template < typename D = Data, enable_if_t<is_same<decltype(D::first), Key>::value, nullptr_t> = nullptr> inline Key dtok(const D& dat) const { return dat.first; } void reallocate(u32 ncap) { vector<Data> ndata(ncap); vector<bool> nf(ncap); shift = 64 - __lg(ncap); for (u32 i = 0; i < cap; i++) { if (flag[i] == true && dflag[i] == false) { u32 h = hash(data[i]); while (nf[h]) h = (h + 1) & (ncap - 1); ndata[h] = move(data[i]); nf[h] = true; } } data.swap(ndata); flag.swap(nf); cap = ncap; dflag.resize(cap); fill(std::begin(dflag), std::end(dflag), false); } inline bool extend_rate(u32 x) const { return x * 2 >= cap; } inline bool shrink_rate(u32 x) const { return HASHMAP_DEFAULT_SIZE < cap && x * 10 <= cap; } inline void extend() { reallocate(cap << 1); } inline void shrink() { reallocate(cap >> 1); } public: u32 cap, s; vector<Data> data; vector<bool> flag, dflag; u32 shift; static u64 r; static constexpr uint32_t HASHMAP_DEFAULT_SIZE = 4; explicit HashMapBase() : cap(HASHMAP_DEFAULT_SIZE), s(0), data(cap), flag(cap), dflag(cap), shift(64 - __lg(cap)) {} itr begin() const { u32 h = 0; while (h != cap) { if (flag[h] == true && dflag[h] == false) break; h++; } return itr(h, this); } itr end() const { return itr(this->cap, this); } friend itr begin(const HashMapBase& h) { return h.begin(); } friend itr end(const HashMapBase& h) { return h.end(); } itr find(const Key& key) const { u32 h = inner_hash(key); while (true) { if (flag[h] == false) return this->end(); if (dtok(data[h]) == key) { if (dflag[h] == true) return this->end(); return itr(h, this); } h = (h + 1) & (cap - 1); } } bool contain(const Key& key) const { return find(key) != this->end(); } itr insert(const Data& d) { u32 h = hash(d); while (true) { if (flag[h] == false) { if (extend_rate(s + 1)) { extend(); h = hash(d); continue; } data[h] = d; flag[h] = true; ++s; return itr(h, this); } if (dtok(data[h]) == dtok(d)) { if (dflag[h] == true) { data[h] = d; dflag[h] = false; ++s; } return itr(h, this); } h = (h + 1) & (cap - 1); } } itr erase(itr it, bool get_next = true) { if (it == this->end()) return this->end(); s--; if (shrink_rate(s)) { Data d = data[it.i]; shrink(); it = find(dtok(d)); } int ni = (it.i + 1) & (cap - 1); if (this->flag[ni]) { this->dflag[it.i] = true; } else { this->flag[it.i] = false; } if (get_next) ++it; return it; } itr erase(const Key& key) { return erase(find(key)); } bool empty() const { return s == 0; } int size() const { return s; } void clear() { fill(std::begin(flag), std::end(flag), false); fill(std::begin(dflag), std::end(dflag), false); s = 0; } void reserve(int n) { if (n <= 0) return; n = 1 << min(23, __lg(n) + 2); if (cap < u32(n)) reallocate(n); } }; template <typename Key, typename Data> uint64_t HashMapBase<Key, Data>::r = chrono::duration_cast<chrono::nanoseconds>( chrono::high_resolution_clock::now().time_since_epoch()) .count(); }
template <typename Key, typename Val> struct HashMap : HashMapImpl::HashMapBase<Key, pair<Key, Val>> { using base = typename HashMapImpl::HashMapBase<Key, pair<Key, Val>>; using HashMapImpl::HashMapBase<Key, pair<Key, Val>>::HashMapBase; using Data = pair<Key, Val>; Val& operator[](const Key& k) { typename base::u32 h = base::inner_hash(k); while (true) { if (base::flag[h] == false) { if (base::extend_rate(base::s + 1)) { base::extend(); h = base::hash(k); continue; } base::data[h].first = k; base::data[h].second = Val(); base::flag[h] = true; ++base::s; return base::data[h].second; } if (base::data[h].first == k) { if (base::dflag[h] == true) base::data[h].second = Val(); return base::data[h].second; } h = (h + 1) & (base::cap - 1); } } typename base::itr emplace(const Key& key, const Val& val) { return base::insert(Data(key, val)); } bool count(const Key& k) { return this->contain(k); } };
template<typename T> HashMap<T, ll> Counter(const vector<T> &A) { HashMap<T, ll> res; for (T a : A) { res[a]++; } return res; } template<typename T> vector<ll> Counter(const vector<T> &A, int mx) { vector<ll> res(mx+1); for (T a : A) { res[a]++; } return res; } HashMap<char, ll> Counter(const string &S) { HashMap<char, ll> res; for (char c : S) { res[c]++; } return res; } template<typename T> vector<pair<ll, T>> most_common(const HashMap<T, ll>& C) { vector<pair<ll, T>> res; for (auto [k, v] : C) { res.eb(v, k); } sort(res.rbegin(), res.rend()); return res; }
template<typename F> ll bisearch_min(ll mn, ll mx, const F &func) { ll ok = mx; ll ng = mn; while (ng+1 < ok) { ll mid = (ok+ng) / 2; if (func(mid)) { ok = mid; } else { ng = mid; } } return ok; } template<typename F> ll bisearch_max(ll mn, ll mx, const F &func) { ll ok = mn; ll ng = mx; while (ok+1 < ng) { ll mid = (ok+ng) / 2; if (func(mid)) { ok = mid; } else { ng = mid; } } return ok; }
template<typename T1, typename T2> pair<vector<T1>, vector<T2>> zip(const vector<pair<T1, T2>> &A) { int N = A.size(); pair<vector<T1>, vector<T2>> res = {vector<T1>(N), vector<T2>(N)}; rep(i, N) { res.first[i] = A[i].first; res.second[i] = A[i].second; } return res; } template<typename T1, typename T2, typename T3> tuple<vector<T1>, vector<T2>, vector<T3>> zip(const vector<tuple<T1, T2, T3>> &A) { int N = A.size(); tuple<vector<T1>, vector<T2>, vector<T3>> res = {vector<T1>(N), vector<T2>(N), vector<T3>(N)}; rep(i, N) { get<0>(res)[i] = get<0>(A[i]); get<1>(res)[i] = get<1>(A[i]); get<2>(res)[i] = get<2>(A[i]); } return res; }
template<typename T> struct Compress { int N; vector<T> dat; bool built = false; Compress() {} Compress(const vector<T> &A) : dat(A) { build(); } void build() { sort(dat.begin(), dat.end()); dat.erase(unique(dat.begin(), dat.end()), dat.end()); N = dat.size(); built = true; } void add(T x) { assert(not built); dat.eb(x); } int zip(T x) { assert(built); return bisect_left(dat, x); } T unzip(int x) { assert(built); return dat[x]; } int operator[](T x) { return zip(x); } int size() { assert(built); return dat.size(); } vector<ll> zip(const vector<T> &A) { int M = A.size(); vector<ll> res(M); rep(i, M) res[i] = zip(A[i]); return res; } };
template<typename T> vector<pair<T, int>> RLE(const vector<T> &A) { if (A.empty()) return {}; int N = A.size(); vector<pair<T, int>> res; T cur = A[0]; int cnt = 1; rep(i, 1, N) { if (A[i] == A[i-1]) { cnt++; } else { res.pb({cur, cnt}); cnt = 1; cur = A[i]; } } res.pb({cur, cnt}); return res; } vector<pair<char, int>> RLE(const string &S) { if (S.empty()) return {}; int N = S.size(); vector<pair<char, int>> res; char cur = S[0]; int cnt = 1; rep(i, 1, N) { if (S[i] == S[i-1]) { cnt++; } else { res.pb({cur, cnt}); cnt = 1; cur = S[i]; } } res.pb({cur, cnt}); return res; }
template<typename T> bool mul_overflow(T x, T y) { T z; return __builtin_mul_overflow(x, y, &z); }
vector<ll> split(const string &S, char separator) { int N = S.size(); vector<ll> res; string cur; rep(i, N) { if (S[i] == separator) { res.eb(toint(cur)); cur = ""; } else { cur += S[i]; } } if (cur.size()) res.eb(toint(cur)); return res; }
string to_string(const string &S) { return S; } string to_string(char c) { return {c}; }
template<typename T> string join(const vector<T> &A, char separator=0) { int N = A.size(); string res; rep(i, N) { res += tostr(A[i]); if (separator != 0 and i != N-1) res += separator; } return res; }
template<typename T> vector<T> sorted(vector<T> A, bool reverse=false) { sort(ALL(A)); if (reverse) std::reverse(ALL(A)); return A; } string sorted(string S, bool reverse=false) { sort(ALL(S)); if (reverse) std::reverse(ALL(S)); return S; }
template<typename T> vector<T> reversed(vector<T> A) { reverse(ALL(A)); return A; } string reversed(string S) { reverse(ALL(S)); return S; }
template<typename T> vector<T> concat(const vector<T>& A, const vector<T>& B) { vector<T> res = A; res.insert(res.end(), B.begin(), B.end()); return res; }
template<typename T> vector<T> subarray(const vector<T>& A, int l, int r) { return vector<T>(A.begin()+l, A.begin()+r); }
template <typename Key> struct HashSet : HashMapImpl::HashMapBase<Key, Key> { using HashMapImpl::HashMapBase<Key, Key>::HashMapBase; bool count(const Key& k) { return this->contain(k); } };
template<typename Mint> struct ModTools { int MAX; vector<Mint> _fact, _factinv, inv; ModTools(int mx) : MAX(++mx) { _fact.resize(MAX); _factinv.resize(MAX); inv.resize(MAX); _fact[0] = _fact[1] = 1; rep(i, 2, MAX) { _fact[i] = _fact[i-1]*(Mint)i; } _factinv[MAX-1] = (Mint)1/_fact[MAX-1]; rep(i, MAX-2, -1, -1) { _factinv[i] = _factinv[i+1]*(Mint)(i+1); } rep(i, MAX-1, 0, -1) { inv[i] = _factinv[i]*_fact[i-1]; } } Mint div(Mint a, int b) { return a*inv[b]; } Mint fact(int x) { assert(x < MAX); return _fact[x]; } Mint factinv(int x) { assert(x < MAX); return _factinv[x]; } Mint nCr(int n, int r) { if (n < r or r < 0) return 0; r = min(r, n-r); Mint num = _fact[n]; Mint den = _factinv[r] * _factinv[n-r]; return num * den; } Mint nHr(int n, int r) { assert(r+n-1 < MAX); return nCr(r+n-1, r); } Mint nPr(int n, int r) { if (n < r or r < 0) return 0; return _fact[n] * _factinv[n-r]; } Mint double_factorial(int n) { if (n%2 == 0) { int k = n/2; return Mint(2).pow(k)*fact(k); } else { int k = (n+1)/2; return fact(2*k)/Mint(2).pow(k)/fact(k); } } };
template<typename T> vector<vector<T>> permutations(const vector<T> &A, int N=-1) { if (N == -1) N = A.size(); int M = A.size(); assert(N <= M); vector<vector<T>> comb; rep(bit, 1<<M) { if (popcount(bit) != N) continue; vector<T> res; rep(i, M) { if (bit>>i & 1) { res.pb(A[i]); } } comb.pb(res); } vector<vector<T>> res; for (auto &perm : comb) { sort(ALL(perm)); do { res.pb(perm); } while (next_permutation(ALL(perm))); } return res; }
template<typename T> vector<vector<T>> combinations(const vector<T> &A, int N) { int M = A.size(); vector<vector<T>> res; auto rec = [&](auto&& f, vector<T> &cur, ll x, ll n) -> void { if (n == N) { res.pb(cur); return; } rep(i, x, M) { cur.pb(A[i]); f(f, cur, i+1, n+1); cur.pop_back(); } }; vector<T> cur; rec(rec, cur, 0, 0); return res; }
ll nC2(ll n) { if (n < 2) return 0; return n*(n-1)/2; }
template<typename T> T factorial(int x) { T res = 1; for (int i=1; i<=x; i++) res *= i; return res; }
struct UnionFind { int n, groupcnt; vector<int> par, rank, sz; vector<bool> tree; UnionFind(int n) : n(n) { build(); } UnionFind() {} UnionFind(const vector<int>& info) : n(info.size()) { build(); vvi adj(n); rep(i, n) { adj[info[i]].eb(i); } rep(i, n) { if (adj[i].size()) { rep(j, adj[i].size()-1) { merge(adj[i][j], adj[i][j+1]); } } } } void build() { par.assign(n, 0); rank.assign(n, 0); sz.assign(n, 1); tree.assign(n, true); rep(i, n) par[i] = i; groupcnt = n; } void resize(int _n) { n = _n; par.assign(n, 0); rank.assign(n, 0); sz.assign(n, 1); tree.assign(n, true); rep(i, n) par[i] = i; groupcnt = n; } virtual int find(int x) { if (par[x] == x) { return x; } else { par[x] = find(par[x]); return par[x]; } } int merge(int a, int b) { int x = find(a); int y = find(b); if (x == y) { tree[x] = false; return -1; } if (!tree[x] or !tree[y]) { tree[x] = tree[y] = false; } groupcnt--; if (rank[x] < rank[y]) { par[x] = y; sz[y] += sz[x]; return y; } else { par[y] = x; sz[x] += sz[y]; if (rank[x] == rank[y]) { rank[x]++; } return x; } } bool same(int a, int b) { return find(a) == find(b); } ll size(int x) { return sz[find(x)]; } int size() { return groupcnt; } bool is_tree(int x) { return tree[find(x)]; } set<int> get_roots() { set<int> res; rep(i, n) { res.insert(find(i)); } return res; } vector<int> get_info() { vector<int> res(n); rep(i, n) { res[i] = find(i); } return res; } };
const vector<pii> dir4 = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
#define directions dir4
ll gridtoid(ll i, ll j, ll W) { return i*W+j; }
pll idtogrid(ll id, ll W) { return divmod(id, W); }
template<typename _Key, typename _Tp> struct defaultdict : HashMap<_Key, _Tp> { const _Tp init; defaultdict() : init(_Tp()) {}; defaultdict(_Tp init) : init(init) {} _Tp& operator[](const _Key& k) { if (this->count(k)) { return HashMap<_Key, _Tp>::operator[](k); } else { return HashMap<_Key, _Tp>::operator[](k) = init; } } _Tp& operator[](_Key&& k) { if (this->count(k)) { return HashMap<_Key, _Tp>::operator[](k); } else { return HashMap<_Key, _Tp>::operator[](k) = init; } } };
template<typename T> T gcd(T a, T b) { while (b) { T t = a % b; a = b; b = t; } return a; } template<typename T> T gcd(const vector<T> &A) { T res = 0; for (auto a : A) res = gcd(res, a); return res; }
template<typename T> T lcm(T x, T y) { return x/gcd(x, y)*y; } template<typename T> T lcm(const vector<T> &A) { T res = 1; for (auto a : A) res = lcm(res, a); return res; }
template<typename T> vector<pair<T, int>> factorize(T n) { vector<pair<T, int>> ret; for (T i=2; i*i<=n; i++) { int cnt = 0; while (n % i == 0) { n /= i; cnt++; } if (cnt) ret.emplace_back(i, cnt); } if (n > 1) ret.emplace_back(n, 1); return ret; }
template<typename T> vector<T> divisors(T n) { vector<T> res; for (T i=1; i*i<=n; i++) { if (n%i == 0) { res.eb(i); if (n/i != i) res.eb(n/i); } } return res; }
ll isqrt(ll n, bool ceil=false) { ll ok = 0; ll ng = 3037000500; while (ng - ok > 1) { ll m = ok + (ng - ok) / 2; if (m * m <= n) { ok = m; } else { ng = m; } } if (ceil and ok*ok != n) ok++; return ok; }
template<typename T> struct Accumulate { vector<T> dat; int N; bool built = false; Accumulate(int N) : N(N) { dat.resize(N); } Accumulate(const vector<T> &A) : N(A.size()), dat(A) { build(); } void set(int i, T a) { dat[i] = a; } void add(int i, T a) { dat[i] += a; } void build() { rep(i, N-1) { dat[i+1] += dat[i]; } dat.insert(dat.begin(), 0); built = true; } virtual T query(int l, int r) { assert(built); assert(0 <= l and l <= N and 0 <= r and r <= N); return dat[r] - dat[l]; } T get(int i) { return query(i, i+1); } T operator[](int i) { return query(i, i+1); } ll bisearch_fore(int l, int r, ll x) { if (l > r) return -1; ll l_sm = query(0, l); int ok = r + 1; int ng = l - 1; while (ng+1 < ok) { int mid = (ok+ng) / 2; if (query(0, mid+1) - l_sm >= x) { ok = mid; } else { ng = mid; } } if (ok != r+1) { return ok; } else { return -1; } } ll bisearch_back(int l, int r, ll x) { if (l > r) return -1; ll r_sm = query(0, r+1); int ok = l - 1; int ng = r + 1; while (ok+1 < ng) { int mid = (ok+ng) / 2; if (r_sm - query(0, mid) >= x) { ok = mid; } else { ng = mid; } } if (ok != l-1) { return ok; } else { return -1; } } };
template<typename T> class BIT { private: int n; vector<T> dat; public: BIT() =  default; explicit BIT(int n) : n(n) { dat.assign(n+1, 0); } explicit BIT(const vector<T> &v) : BIT((int)v.size()) { build(v); } void build(const vector<T> &v) { assert(n == (int)v.size()); for (int i = 1; i <= n; i++) { dat[i] = v[i - 1]; } for (int i = 1; i <= n; i++) { int j = i + (i & -i); if (j <= n) dat[j] += dat[i]; } } T sum(int r) { T s = T(); for (; r > 0; r -= r & -r) { s += dat[r]; } return s; } void add(int k, const T &x) { for (++k; k <= n; k += k & -k) { dat[k] += x; } } T query(int l, int r) { if (l >= r) return 0; return sum(r) - sum(l); } T get(int i) { return query(i, i+1); } void update(int i, T x) { add(i, x-get(i)); } T operator[](int i) { return query(i, i+1); } void print() { rep(i, n) { cout << query(i, i+1); if (i == n-1) cout << endl; else cout << ' '; } } ll bisearch_fore(int l, int r, ll x) { if (l > r) return -1; ll l_sm = sum(l); int ok = r + 1; int ng = l - 1; while (ng+1 < ok) { int mid = (ok+ng) / 2; if (sum(mid+1) - l_sm >= x) { ok = mid; } else { ng = mid; } } if (ok != r+1) { return ok; } else { return -1; } } ll bisearch_back(int l, int r, ll x) { if (l > r) return -1; ll r_sm = sum(r+1); int ok = l - 1; int ng = r + 1; while (ok+1 < ng) { int mid = (ok+ng) / 2; if (r_sm - sum(mid) >= x) { ok = mid; } else { ng = mid; } } if (ok != l-1) { return ok; } else { return -1; } } int lower_bound(T x) const { int i = 0; for (int k = 1 << (__lg(n) + 1); k > 0; k >>= 1) { if (i + k <= n && dat[i+k] < x) { x -= dat[i+k]; i += k; } } return i; } int upper_bound(T x) const { int i = 0; for (int k = 1 << (__lg(n) + 1); k > 0; k >>= 1) { if (i + k <= n && dat[i+k] <= x) { x -= dat[i+k]; i += k; } } return i; } };
template<typename Monoid, typename F> struct SegmentTree { int sz; vector<Monoid> seg; const F f; const Monoid M1; SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) { sz = 1; while(sz < n) sz <<= 1; seg.assign(2 * sz, M1); } SegmentTree(const F f, const Monoid &M1) : f(f), M1(M1) {} SegmentTree(const vector<Monoid>& A, const F f, const Monoid &M1) : f(f), M1(M1) { build(A); } void resize(int n) { sz = 1; while(sz < n) sz <<= 1; seg.resize(2 * sz, M1); } void clear() { seg.clear(); } void set(int k, const Monoid &x) { seg[k+sz] = x; } void build() { for(int k = sz - 1; k > 0; k--) { seg[k] = f(seg[2*k], seg[2*k+1]); } } void build(const vector<Monoid> &A) { int n = A.size(); resize(n); rep(i, n) set(i, A[i]); build(); } void update(int k, const Monoid &x) { k += sz; seg[k] = x; while(k >>= 1) { seg[k] = f(seg[2*k], seg[2*k+1]); } } Monoid query(int a, int b) { Monoid L = M1, R = M1; for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) { if(a & 1) L = f(L, seg[a++]); if(b & 1) R = f(seg[--b], R); } return f(L, R); } Monoid operator[](const int &k) const { return seg[k+sz]; } Monoid all() { return seg[1]; } void print(int n) { for (int i=0; i<n; i++) { cout << query(i, i+1); if (i == n-1) cout << endl; else cout << ' '; } } template<typename C> int find_subtree(int a, const C &check, Monoid &M, bool type) { while(a < sz) { Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]); if(check(nxt)) a = 2 * a + type; else M = nxt, a = 2 * a + 1 - type; } return a - sz; } template<typename C> int find_first(int a, const C &check) { Monoid L = M1; if(a <= 0) { if(check(f(L, seg[1]))) return find_subtree(1, check, L, false); return -1; } int b = sz; for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) { if(a & 1) { Monoid nxt = f(L, seg[a]); if(check(nxt)) return find_subtree(a, check, L, false); L = nxt; ++a; } } return -1; } template<typename C> int find_last(int b, const C &check) { Monoid R = M1; if(b >= sz) { if(check(f(seg[1], R))) return find_subtree(1, check, R, true); return -1; } int a = sz; for(b += sz; a < b; a >>= 1, b >>= 1) { if(b & 1) { Monoid nxt = f(seg[--b], R); if(check(nxt)) return find_subtree(b, check, R, true); R = nxt; } } return -1; } }; template<typename Monoid, typename F> SegmentTree<Monoid, F> get_segment_tree(int N, const F& f, const Monoid& M1) { return {N, f, M1}; } template<typename Monoid, typename F> SegmentTree<Monoid, F> get_segment_tree(const F& f, const Monoid& M1) { return {f, M1}; } template<typename Monoid, typename F> SegmentTree<Monoid, F> get_segment_tree(const vector<Monoid>& A, const F& f, const Monoid& M1) { return {A, f, M1}; }
const string digits = "0123456789";
const string ascii_lowercase = "abcdefghijklmnopqrstuvwxyz";
const string ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string zfill(string str, int len) { string zeros; int n = str.size(); rep(i, len-n) zeros += '0'; return zeros+str; }
string bin(ll x) { string res; while (x) { if (x & 1) { res += '1'; } else { res += '0'; } x >>= 1; } reverse(ALL(res)); if (res == "") res += '0'; return res; }

void solve() {
    ll P[2], T[2];
    rep(i, 2) {
        cin >> P[i] >> T[i];
    }
    ll H, S;
    cin >> H >> S;

    // dp[h] := ダメージをh与えて同時打ち直後の状態となる最小所要時間
    vector<ll> dp(H+1, INF);
    dp[0] = 0;
    ll ans = INF;
    rep(h, H) {
        // p[a]をi回打ってから次の同時打ち
        rep(i, 1, H+1) {
            rep(a, 2) {
                ll b = 1 - a;
                // T[a]をi回打つ所要時間
                ll xa = i * T[a];
                // T[a]をi回打った時点までにT[b]も打てるだけ打つ
                ll j = xa / T[b];
                // xa以下で最大のT[b]の倍数
                ll xb = j * T[b];
                ll nxh = h + (P[a]-S)*i + (P[b]-S)*j;
                // ダメージがH以上に達していれば、これも答えに使う
                if (nxh >= H) {
                    chmin(ans, dp[h] + xa);
                }

                // T[a]をi回打った後、T[b]も整うまで待って同時打ち
                j = ceil(xa, T[b]);
                // xa以上で最小のT[b]の倍数
                xb = j * T[b];
                nxh = h + (P[a]+P[b]-S) + (P[a]-S)*(i-1) + (P[b]-S)*(j-1);
                // 次の同時内が終わった時点に遷移
                if (nxh <= H) {
                    chmin(dp[nxh], dp[h] + xb);
                }
            }
        }
    }
    chmin(ans, dp[H]);
    print(ans);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    // single test case
    solve();

    // multi test cases
    // int T;
    // cin >> T;
    // while (T--) solve();

    return 0;
}

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using uint = unsigned int; using ull = unsigned long long; using ld = long double; using i128 = __int128_t;
using P = pair<int, int>; using LP = pair<ll, ll>; using LT = tuple<ll, ll, ll>; using LT4 =  tuple<ll, ll, ll, ll>;
typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> v3l; typedef vector<v3l> v4l; typedef vector<v4l> v5l;
typedef vector<LP> vlp; typedef vector<vlp> vvlp; typedef vector<LT> vlt; typedef vector<vlt> vvlt; typedef vector<LT4> vlt4; typedef vector<string> vs; typedef vector<vs> vvs;
typedef vector<ld> vd; typedef vector<vd> vvd; typedef vector<bool> vb; typedef vector<vb> vvb;
template<typename T> using pq = priority_queue<T>; template<typename T> using mpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T> class infinity{ public: static constexpr T MAX=numeric_limits<T>::max(); static constexpr T MIN=numeric_limits<T>::min(); static constexpr T val=numeric_limits<T>::max()/2-1e6; static constexpr T mval=numeric_limits<T>::min()/2+1e6; };
const int INF = infinity<int>::val; const ll LINF = infinity<ll>::val; const ld DINF = infinity<ld>::val;
#define _overload5(a, b, c, d, e, name, ...) name
#define _overload4(a, b, c, d, name, ...) name
#define _overload3(a, b, c, name, ...) name
#define _rep0(n) for(ll i = 0; (ll)(i) < n; ++i)
#define _rep1(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define _rep2(i, a, b) for(ll i = (ll)(a); i < (ll)(b); ++i)
#define _rep3(i, a, b, c) for(ll i = (ll)(a); i < (ll)(b); i += (ll)(c))
#define rep(...) _overload4(__VA_ARGS__, _rep3, _rep2, _rep1, _rep0)(__VA_ARGS__)
#define _per0(n) for(ll i = 0; i < (ll)(n); ++i)
#define _per1(i, n) for(ll i = (ll)(n)-1; i >= 0; --i)
#define _per2(i, a, b) for(ll i = (ll)(b)-1; i >= (ll)(a); --i)
#define _per3(i, a, b, c) for(ll i = (ll)(b)-1; i >= (ll)(a); i -= (ll)(c))
#define rep_r(...) _overload4(__VA_ARGS__, _per3, _per2, _per1, _per0)(__VA_ARGS__)
#define _fore0(a) rep(a.size())
#define _fore1(i, a) for(auto &&i : a)
#define _fore2(a, b, v) for(auto &&[a, b] : v)
#define _fore3(a, b, c, v) for(auto &&[a, b, c] : v)
#define _fore4(a, b, c, d, v) for(auto &&[a, b, c, d] : v)
#define fore(...) _overload5(__VA_ARGS__, _fore4, _fore3, _fore2, _fore1, _fore0)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define rng_of(v, l, r) (v).begin() + l, (v).begin() + r
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define v3(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define v4(type, name, a, b, c, ...) vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

struct RandGen {
  using ud = uniform_int_distribution<ll>; mt19937 mt; RandGen() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}
  ll l(ll a, ll b) { ud d(a, b - 1); return d(mt); }
  LP lp(ll a, ll b, bool rng = true) { ll x = l(a, b - 1), y = l(rng ? x + 1 : a, b - 1); return {x, y}; }
  vl vecl(ll n, ll a, ll b) { ud d(a, b - 1); vl ret(n); rep(i, n) ret[i] = d(mt); return ret; }
  vl vecperm(ll n, ll from = 0) { vl perm(n); iota(all(perm), from); shuffle(perm); return perm; }
  string str(ll n, string op) { vl fig = vecl(n, 0, op.size()); string s; rep(i, n) s.pb(op[fig[i]]); return s; }
  string straz(ll n, ll a = 0, ll z = 26) { vl az = vecl(n, a, z); string s; rep(i, n) s.pb('a' + az[i]); return s; }
  string strnum(ll n, ll zero = 0, ll ten = 10) { vl zt = vecl(n, zero, ten); string s; rep(i, n) s.pb('0' + zt[i]); return s; }
  template<typename T> void shuffle(vector<T> &a) { std::shuffle(all(a), mt); }
};
// デバッグ系
#define dout cout
template<typename T, typename=void> struct is_specialize:false_type{};
template<typename T> struct is_specialize<T, typename conditional<false,typename T::iterator, void>::type>:true_type{};
template<typename T> struct is_specialize<T, typename conditional<false,decltype(T::first), void>::type>:true_type{};
template<typename T> struct is_specialize<T, enable_if_t<is_integral<T>::value, void>>:true_type{};
void dump(const char &t) { dout<<t; } void dump(const string &t) { dout<<t; } void dump(const bool &t) { dout<<(t ? "true" : "false"); }
template<typename T, enable_if_t<!is_specialize<T>::value, nullptr_t> =nullptr> void dump(const T&t) { dout << t; }
template<typename T> void dump(const T&t, enable_if_t<is_integral<T>::value>* =nullptr) { string tmp;if(t==infinity<T>::val||t==infinity<T>::MAX)tmp="inf";if(is_signed<T>::value&&(t==infinity<T>::mval||t==infinity<T>::MIN))tmp="-inf";if(tmp.empty())tmp=to_string(t);dout<<tmp; }
template<typename T, typename U, typename V> void dump(const tuple<T, U, V>&t) { dout<<"("; dump(get<0>(t)); dout<<" "; dump(get<1>(t)); dout << " "; dump(get<2>(t)); dout << ")"; }
template<typename T, typename U, typename V, typename S> void dump(const tuple<T, U, V, S>&t) { dout<<"("; dump(get<0>(t)); dout<<" "; dump(get<1>(t)); dout << " "; dump(get<2>(t)); dout << " "; dump(get<3>(t)); dout << ")"; }
template<typename T,typename U> void dump(const pair<T,U>&);
template<typename T> void dump(const T&t, enable_if_t<!is_void<typename T::iterator>::value>* =nullptr) { dout << "{ "; for(auto it=t.begin();it!=t.end();){ dump(*it); dout << (++it==t.end() ? "" : " "); } dout<<" }"; }
template<typename T,typename U> void dump(const pair<T,U>&t) { dout<<"("; dump(t.first); dout<<" "; dump(t.second); dout << ")"; }
void trace() { dout << "\n"; } template<typename Head, typename... Tail> void trace(Head&&head, Tail&&... tail) { dump(head); if(sizeof...(tail)) dout<<", "; trace(forward<Tail>(tail)...); }
#ifdef ONLINE_JUDGE
#define debug(...) (void(0))
#else
#define debug(...) do {dout<<#__VA_ARGS__<<" = ";trace(__VA_ARGS__); } while(0)
#endif
// 入出力系
#define LL(...) ll __VA_ARGS__; IN(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__; IN(__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__; IN(__VA_ARGS__)
#define _vl(name, size) vl name(size); IN(name)
#define _vl2(name, size, off) vl name(size); IN(name); rep(i, size) name[i]-=off
#define VL(...) _overload3(__VA_ARGS__, _vl2, _vl)(__VA_ARGS__)
#define VEC(type, name, size) vector<type> name(size); IN(name)
#define VEC2(type, name1, name2, size) vector<type> name1(size), name2(size); for(int i = 0; i < size; i++) IN(name1[i], name2[i])
#define VEC3(type, name1, name2, name3, size) vector<type> name1(size), name2(size), name3(size); for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i])
#define VEC4(type, name1, name2, name3, name4, size) vector<type> name1(size), name2(size), name3(size), name4(size); for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i], name4[i]);
#define VV(type, name, h, w) vector<vector<type>> name(h, vector<type>(w)); IN(name)
void scan(int &a) { cin >> a; } void scan(long long &a) { cin >> a; } void scan(char &a) { cin >> a; } void scan(double &a) { cin >> a; } void scan(string &a) { cin >> a; }
template <class T> void scan(T &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
void IN() {} template <class Head, class... Tail> void IN(Head &head, Tail &...tail) { scan(head); IN(tail...); }
#define OUTRET(...) { { OUT(__VA_ARGS__); return; } }
template <class T, class S> ostream &operator<<(ostream &os, const pair<T, S> &p) { return os << p.first << " " << p.second; }
void OUT() { cout << '\n'; } template <typename Head, typename... Tail> void OUT(const Head &head, const Tail &...tail) { cout << head; if(sizeof...(tail)) cout << ' '; OUT(tail...); }
template<class T, class S = ll> void OUTARRAY(vector<T>& v, S offset = S(0), string sep = " ") { rep(i, v.size()) { if (i > 0) cout << sep; if (offset != T(0)) { T t; t = v[i] + offset; cout << t; } else cout << v[i]; } cout << "\n"; }
template<class T, class S = ll> void OUTMAT(vector<vector<T>>& v, S offset = S(0)) { rep(i, v.size()) { OUTARRAY(v[i], offset); } }
template<typename T> void OUTBIN(T &a, int d) { for (int i = d - 1; i >= 0; i--) cout << ((a >> i) & (T)1); cout << "\n"; }
template<typename Q, typename A> void IQUERY(initializer_list<Q> q, A &a, string str = "? ") { cout << str; vector<Q> v(q); OUTARRAY(v); cout.flush(); cin >> a; }
// template<typename Q, typename A> void IQUERY(initializer_list<Q> q, A &a, string str = "? ") { vector<Q> query(q); RandGen rg;
//   a = query[0] ? A() : A();
// }
template<typename A> void IANSWER(initializer_list<A> a, string str = "! ") { cout << str; vector<A> v(a); OUTARRAY(v); cout.flush(); }
// 数値系
int ceil_pow2(ll n) { int x = 0; while ((1ULL << x) < (ull)(n)) x++; return x; }
int floor_pow2(ll n) { int x = 0; while ((1ULL << (x + 1)) <= (ull)(n)) x++; return x; }
pair<ll, ll> sqrtll(ll n) { ll x = round(sqrt(n)); if (x * x > n) --x; return {x, x + (x * x != n)}; }
ll POW(__uint128_t x, int n) { assert(n >= 0); ll res = 1; for(; n; n >>= 1, x *= x) if(n & 1) res *= x; return res; }
vl primes(const ll n) { vb isp(n + 1, true); for(ll i = 2; i * i <= n; i++) { if ((i > 2 && i % 2 == 0) || !isp[i]) continue; for(ll j = i * i; j <= n; j += i) isp[j] = 0; } vl ret; for(ll i = 2; i <= n; i++) if (isp[i]) ret.emplace_back(i); return ret; }
vl divisor(ll n) { vl ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.pb(i); if (i * i != n) ret.pb(n / i); } } sort(all(ret)); return ret; }
template<typename T> vl digits(T n) { assert(n >= 0); vl ret; while(n > 0) { ret.pb(n % 10); n /= 10; } return ret; }
template<class T, enable_if_t<is_integral<T>::value, nullptr_t> = nullptr> int msb(T x){ if (sizeof(x) == 4) return 31 - __builtin_clz(x); else return 63 - __builtin_clzll(x); }
template<class T, enable_if_t<is_integral<T>::value, nullptr_t> = nullptr> int lsb(T x){ if (sizeof(x) == 4) return __builtin_ctz(x); else return __builtin_ctzll(x); }
template<typename T, typename S> T ceil(T x, S y) { assert(y); return (y < 0 ? ceil(-x, -y) : (x > 0 ? (x + y - 1) / y : x / y)); }
template<typename T, typename S> T floor(T x, S y) { assert(y); return (y < 0 ? floor(-x, -y) : (x > 0 ? x / y : (x - y + 1) / y)); }
template<typename T = ll> T sum_of(const vector<T> &v, int l = 0, int r = INF) { return accumulate(rng_of(v, l, min(r, (int)v.size())), T(0)); }
ll max(int x, ll y) { return max((ll)x, y); } ll max(ll x, int y) { return max(x, (ll)y); }
ll min(int x, ll y) { return min((ll)x, y); } ll min(ll x, int y) { return min(x, (ll)y); }
ll mex(vl& v) { ll n = v.size(); vb S(n + 1); for (auto a: v) if (a <= n) S[a] = 1; ll ret = 0; while (S[ret]) ret++; return ret; }
// 操作系
template<class T> void rotate(vector<vector<T>> &a) { ll n = a.size(), m = a[0].size(); vector<vector<T>> ret(m, vector<T>(n, 0)); rep(i, n) rep(j, m) ret[j][n - 1 - i] = a[i][j]; a = ret; }
template<typename T> void uniq(vector<T>&a) { sort(all(a)); a.erase(unique(all(a)), a.end()); }
template<typename T> void comp(vector<T>&a) { vector<T> b = a; uniq(b); rep(i, a.size()) a[i] = lower_bound(all(b), a[i]) - b.begin(); }
template<class T = ll> pair<unordered_map<ll, ll>, unordered_map<ll, ll>> compmap(vector<T> &a) { vector<T> ca = a; comp(ca); unordered_map<ll, ll> ret, rev; rep(i, ca.size()) { ret[a[i]] = ca[i]; rev[ca[i]] = a[i]; } return mp(ret, rev); }
template<class T, class U> bool chmin(T &a, const U &b) { if (b < a) { a = b; return 1;} return 0; }
template<class T, class U> bool chmax(T &a, const U &b) { if (b > a) { a = b; return 1;} return 0; }
template<class T> int lbs(vector<T> &a, const T &b) { return lower_bound(all(a), b) - a.begin(); };
template<class T> int ubs(vector<T> &a, const T &b) { return upper_bound(all(a), b) - a.begin(); };
ll binary_search(function<bool(ll)> check, ll ok, ll ng, bool safe=true) { if (safe) { assert(check(ok)); assert(!check(ng)); } while (abs(ok - ng) > 1) { auto x = (ng + ok) / 2; if (check(x)) ok = x; else ng = x; } return ok; }
template<class T> vector<T> csum(vector<T> &a) { vl ret(a.size() + 1, 0); rep(i, a.size()) ret[i + 1] = ret[i] + a[i]; return ret; }
template<class S> vector<pair<S, int>> RLE(const vector<S> &v) { vector<pair<S, int>> res; for(auto &e : v) if(res.empty() or res.back().first != e) res.emplace_back(e, 1); else res.back().second++; return res; }
vector<pair<char, int>> RLE(const string &v) { vector<pair<char, int>> res; for(auto &e : v) if(res.empty() or res.back().first != e) res.emplace_back(e, 1); else res.back().second++; return res; }
template <class T, class S, class U> bool incl(const T &x, const S &l, const U &r) { return l <= x and x < r; }
void change_bit(ll &x, int b, int i) { assert(b < 63); if (!!(x & 1ll << b) ^ i) x ^= 1ll << b;  }
bool is_palindrome(string s) { rep(i, (s.size() + 1) / 2) if (s[i] != s[s.size() - 1 - i]) { return false; } return true; }
const string drul = "DRUL"; vl dx = {1, 0, -1, 0}; vl dy = {0, 1, 0, -1};

ll solve(ll n, vl a) {
  ll ans = n - a[0]; return ans;
}

ll naive(ll n, vl a) {
  ll ans = n + a[0]; return ans;
}

void compare(bool check = true) { RandGen rg; ll c = 0, loop = 10;
  while (++c) { if (c % loop == 0) cout << "reached " << c / loop << "loop" <<  "\n", cout.flush();
    ll n = 10;
    vl a = rg.vecl(n, 1, 1e2);
    auto so = solve(n, a); auto na = naive(n, a);
    if (!check || na != so) { cout << c << "times tried" << "\n";
      debug(n, a); debug(so); debug(na);
    if (check || (!check && c > loop)) break; }
  }
}

void solve() {
  LL(p1, t1, p2, t2, h, s);

  // if (t1 == t2) OUTRET(ceil(h, p1 + p2 - s) * t1);
  if (t1 > t2) { swap(t1, t2); swap(p1, p2); }

  vv(ll, dp, h + 1, h + 5, LINF);
  dp[0][0] = 0;

  ll both = p1 + p2 - s;
  p1 -= s; p2 -= s;

  ll ans = LINF;
  rep(i, h + 1) rep(j, h + 1) {
    if (dp[i][j] == LINF) continue;

    // 1を打つ
    if (t1 * (j + 1) / t2 > t1 * j / t2) {
      if (i + p2 >= h) chmin(ans, dp[i][j] + (t1 * j / t2 + 1) * t2);
      chmin(dp[min(h, i + p1)][j + 1], dp[i][j] + t1);
      chmin(dp[min(h, i + both)][0], dp[i][j] + t1);
    } else {
      chmin(dp[min(h, i + p1)][j + 1], dp[i][j] + t1);
      chmin(dp[min(h, i + both)][0], dp[i][j] + t2);
    }
  }

  rep(i, h + 1) chmin(ans, dp[h][i]);
  OUT(ans);
}

signed main() {
  cin.tie(0)->sync_with_stdio(0); cout.tie(0); cout << fixed << setprecision(20);
  int t = 1; //cin >> t;
  while (t--) solve();
  // while (t--) compare();
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return ((b == 0) ? (a) : gcd(b, a % b));}
ll lcm(ll a, ll b) {return (a * b / gcd(a, b));}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll p1, t1, p2, t2, h, s;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
    if (t1 > t2) swap(p1, p2), swap(t1, t2);
    ll ans = 1e18;
    for (ll i = 0; i <= (h / ((t2 / t1 - 1) * (p1 - s) + p1 + p2 - s)); ++i) {
        ll H = h - i * ((t2 / t1 - 1) * (p1 - s) + p1 + p2 - s);
        ll l = 0, r = 1e16;
        while (r - l > 1) {
            ll m = (l + r) / 2;
            if ((p1 - s) * (m / t1) + (p2 - s) * (m / t2) + s * (m / lcm(t1, t2)) >= H) r = m;
            else l = m;
        }
        ans = min(ans, r + i * t2);
    }
    cout << ans;
}

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<=k;++i)
#define For(i,j,k) for(int i=j;i>=k;--i)
#define int long long
const int MAX=2e4+111;
int f[MAX],kill[MAX],t[MAX],cnt;
signed main(){
//	freopen("1.in","r",stdin);
	int p1,t1,p2,t2,h,s;
	cin>>p1>>t1>>p2>>t2>>h>>s;
	FOR(i,1,h) f[i]=1e18;
	FOR(i,1,h/(p1-s)+1){
		t[++cnt]=t1*i;
		if(i*t1>=t2) kill[cnt]=(i-1)*(p1-s)+((i*t1)/t2-1)*(p2-s)+(p1+p2-s);
		else kill[cnt]=i*(p1-s);
	}
	FOR(i,1,h/(p2-s)+1){
		t[++cnt]=t2*i;
		kill[cnt]=(i-1)*p2+((i*t2)/t1-1)*(p1-s)+(p1+p2-s);
	}
	FOR(i,1,cnt){
		FOR(j,0,h){
			if(j>=kill[i]){
				f[j]=min(f[j-kill[i]]+t[i],f[j]);
			}
		}
	}
	cout<<f[h];
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int __int128_t
#define f(i, a, b) for(int i = (a); i <= (b); i++)
#define cl(i, n) i.clear(),i.resize(n);
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int inf = 1e18;
void print(int x){
    string ss;
    while(x){
        ss+=char((x%10)+'0');
        x/=10;

    }
}
ll a,b,c,d,e,f;
int p1,t1,p2,t2,h,s;
int calc(int x,int y){
  //  cout << x <<" "<<y<<endl;
    int nd = x*(p1-s)+y*(p2-s);
    int nt=max(x*t1,y*t2);
    int xx=h-nd;
    int ot=p1+p2-s;
    int tms=(xx+ot-1)/ot;
    int tm=tms*max(t1,t2);
    nt+=tm;
 //   cout<<nt<<endl;
    return nt;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    time_t start = clock();
    //think twice,code once.
    //think once,debug forever.
    cin>>a>>b>>c>>d>>e>>f;
  //  cin>>p1>>t1>>p2>>t2>>h>>s;
    p1=a,t1=b,p2=c,t2=d,h=e,s=f;
    if(t1>t2){
        swap(p1,p2);swap(t1,t2);
    }
    int ans= inf;
//    cout<<(h+(p1-s))/(p1-s)<<" "<<(h+(p2-s))/(p2-s)<<endl;
    f(i, 0, (h+(p1-s))/(p1-s)) f(j, 0,(h+(p2-s))/(p2-s)){
        ans=min(ans,calc(i,j));
    }
    ll anans=ans;
    cout<<anans<<endl;
 //   print(ans);
    time_t finish = clock();
    //cout << "time used:" << (finish-start) * 1.0 / CLOCKS_PER_SEC <<"s"<< endl;
    return 0;
}

/*OM NAMAH SHIVAAY*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace __gnu_pbds; //required
// #include <boost/lexical_cast.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i)
#define forrc(i,r,l) for (int i= (int)(r); i>= (int)(l); --i)

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

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

#define tr(c,i) for(_typeof_((c)).begin() i = (c).begin(); i != (c).end(); i++)

#define present(c,x) ((c).find(x) != (c).end())

#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;

#define count1(x) __builtin_popcount(x)
#define count1ll(x) __builtin_popcountll(x)
#define leadzero(x) __builtin_clz(x)
#define trailzero(x) __builtin_ctz(x)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pair<ll,ll>> vpll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;
//ORDERED STATISTICS TREE
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_map =  tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multimap =  tree<T, int, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
//IMPORTANT FUNCTIONS OF ORDERED STATISTICS TREE:
//order_of_key() : gives number of elements with keys strictly smaller than passed key.
//find_by_order() : gives the iterator to the k_th key.

//unhackable unordered_map and gp_hash_table:-
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ull binpow(ull a, ull b, ull m) {
    a %= m;
    ll rem = 1;
    while (b > 0) {
        if (b & 1)
            rem = rem * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return rem;
}

const int MOD=1000000007;
int no_of_bits(long long n)
{
    int count=0;
    while(n>0)
    {
        n=n>>1;
        count++;
    }
    return count;
}
ll GCD_coeff(ll a, ll b, ll& x, ll& y) {
    x = 1, y = 0;
    ll x1 = 0, y1 = 1, a1 = a, b1 = b;
    while (b1) {
        ll q = a1 / b1;
        tie(x, x1) = make_tuple(x1, x - q * x1);
        tie(y, y1) = make_tuple(y1, y - q * y1);
        tie(a1, b1) = make_tuple(b1, a1 - q * b1);
    }
    return a1;
}
ll LCM(ll a,ll b){
    ll x,y;
    return a/GCD_coeff(a,b,x,y)*b;
}
const int INF=-2000;
const ll INF_=1e13;
ll minll(ll a,ll b){
    if(a>b) return b;
    else return a;
}
ll maxll(ll a,ll b){
    if(a<b) return b;
    else return a;
}
void make_set(vll &parent,vll &rank,int v){
    parent[v]=v;
    rank[v]=0;
}
int find_set(vll &parent,int v){
    if(v==parent[v]){
        return v;
    }
    return parent[v]=find_set(parent,parent[v]);
}
void union_sets(vll &parent,vll &rank,int a,int b){
    a=find_set(parent,a);
    b=find_set(parent,b);
    if(a!=b){
        if(rank[a]<rank[b]){
            swap(a,b);
        }
        parent[b]=a;
        if(rank[a]==rank[b]){
            rank[a]++;
        }
    }
}
int check(map<pair<ll,ll>,int>&mp,ll p1,ll p2,ll t1,ll t2,ll h,ll s,ll t){
    if(h<=0&&s>=0){
        return 2;
    }
    else if(mp[{h,s}]!=0) return mp[{h,s}];
    ll p=0,q=0,r=0;
    if(mp[{h-p1+s,t-t1}]==0){
        if(t-t1>=0){
            mp[{h-p1+s,t-t1}]=check(mp,p1,p2,t1,t2,h-p1+s,s,t-t1);
        }

    }
    if(mp[{h-p2+s,t-t2}]==0){
        if(t-t2>=0){
            mp[{h-p2+s,t-t2}]=check(mp,p1,p2,t1,t2,h-p2+s,s,t-t2);
        }

    }
    if(mp[{h-p1+s-p2,t-maxll(t1,t2)}]==0){
        if(t-maxll(t1,t2)>=0){
            mp[{h-p1+s-p2,t-maxll(t1,t2)}]=check(mp,p1,p2,t1,t2,h-p1+s-p2,s,t-maxll(t1,t2));
        }

    }

    return mp[{h,s}]=maxll(maxll(mp[{h-p1+s,t-t1}],mp[{h-p2+s,t-t2}]),mp[{h-p1+s-p2,t-maxll(t1,t2)}]);
}

void solve(){
    ll p1,t1,p2,t2,h,s;
    cin>>p1>>t1>>p2>>t2>>h>>s;
    ll l=0,r=1e16,ans=1e18;
    while(l<=r){
        ll mid=(l+r)/2;
        map<pair<ll,ll>,int>mp;
        auto p=check(mp,p1,p2,t1,t2,h,s,mid);
        if(p==2){
            ans=minll(ans,mid);
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    cout<<ans<<"\n";
}
int main(){

//  auto start = chrono::high_resolution_clock::now();

    // unsync the I/O of C and C++.
    // ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    // cin>>t;
    t=1;
    int i=0;
    while(i++<t){
        solve();
    }

    // auto end = chrono::high_resolution_clock::now();

    // Calculating total time taken by the program.
    // double time_taken =
    //   chrono::duration_cast<chrono::nanoseconds>(end - start).count();

    // time_taken *= 1e-9;

    // cout << "Time taken by program is : " << fixed
        //  << time_taken << setprecision(9);

}

#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <deque>
#include <string>
#include <ctime>
#include <bitset>
#include <queue>
#include <cassert>
#include<unordered_set>
#include<unordered_map>
#include<string.h>
using namespace std;
#define ll long long
#define ld long double
#define int long long
#define ull unsigned long long
#define pi pair<int, int>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
const ll INF = 1e18 + 2;
const ll HASHMOD1 = 998244353;
const ull MOD3 = (1ll << 32);
vector<int> dX = { 1, 0, -1, 0 };
vector<int> dY = { 0, 1, 0, -1 };
int NOD(int a, int b) {
    return b ? NOD(b, a % b) : a;
}
const int block_size = 800;
class Query {
public:
    int l = 0;
    int r = 0;
    int idx = 0;
    Query(int L, int R, int Num) {
        l = L;
        r = R;
        idx = Num;
    }
};
bool cmp(Query& q1, Query& q2) {
    if (q1.r == q2.r) return q1.l < q2.l;
    return q1.r < q2.r;
}
vector<vector<int>> dp;
void solve() {
    int P1 = 0, T1 = 0; cin >> P1 >> T1;
    int P2 = 0, T2 = 0; cin >> P2 >> T2;
    int H = 0, S = 0; cin >> H >> S;
    dp.assign(H + 1, vector<int>(4, INF));
    dp[0][0] = 0;
    int a = H / (P1 - S); a++;
    int b = H / (P2 - S); b++;
    int ans = INF;
    for (int pickone = 0; pickone <= a; ++pickone) {
        for (int picktwo = 0; picktwo <= b; ++picktwo) {
            int leftH = H - pickone * (P1 - S) - picktwo * (P2 - S);
            if (leftH <= 0) {
                ans = min(ans, max(pickone * T1, picktwo * T2));
                continue;
            }
            int lleft = H / (P1 + P2 - S); if (H % (P1 + P2 - S) != 0) lleft++;
            ans = min(ans, lleft * max(T1, T2) + max(pickone * T1, picktwo * T2));
        }
    }
    cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>

using namespace std;

const int maxn=1000200;

long long p1,p2,t1,t2,h,s,ans;
long long f[maxn];

int main()
{
	ios::sync_with_stdio(false);
	cin>>p1>>t1; cin>>p2>>t2;
	cin>>h>>s;
	memset(f,0x3f,sizeof(f)); f[0]=0;
	ans=f[1];
	for(int i=min(p1,p2);i<=h+max(p1-s,p2-s);i++)
	{
		if(i>=(p1-s)) f[i]=min(f[i],f[i-(p1-s)]+t1);
		if(i>=(p2-s)) f[i]=min(f[i],f[i-(p2-s)]+t2);
		if(i>=h) ans=min(ans,f[i]);
		for(int j=max(1ll,t2/t1);;j++)
		{
			long long timecost=t1*j;
			if(timecost<t2) continue;
			long long attack=1ll*(j-1)*(p1-s);
			attack+=max(timecost/t2-1,0ll)*(p2-s);
			attack+=(p1+p2-s);
			if(i<attack) break;
			f[i]=min(f[i-attack]+timecost,f[i]);
			if(i>=h) ans=min(ans,f[i]);
		}
		for(int j=max(1ll,t1/t2);;j++)
		{
			long long timecost=t2*j;
			if(timecost<t1) continue;
			long long attack=1ll*(j-1)*(p2-s);
			attack+=max(timecost/t1-1,0ll)*(p1-s);
			attack+=(p1+p2-s);
			if(i<attack) break;
			f[i]=min(f[i-attack]+timecost,f[i]);
			if(i>=h) ans=min(ans,f[i]);
		}
		for(int j=h+max(p1-s,p2-s);j;j--) f[j]=min(f[j+1],f[j]);
	}
	cout<<ans<<endl;
}

// Problem: E. FTL
// URL: https://codeforces.com/contest/1743/problem/E
// Group: Codeforces - Educational Codeforces Round 137 (Rated for Div. 2)
// Time: 2022-10-17 22:35
// Author: lingfunny

#include <bits/stdc++.h>
#define LL long long
using namespace std;

const int mxn = 1e4 + 10;
const LL inf = 1e18;

int p1, p2, h, s;
LL t1, t2, f[mxn];
// 0 represent used

signed main() {
	scanf("%d%lld%d%lld%d%d", &p1, &t1, &p2, &t2, &h, &s);
	for (int i = 1; i <= h; ++i) f[i] = inf;
	for (int i = 1; i <= h; ++i) {
		if (p1 > s) f[i] = min(f[i], f[max(i - (p1 - s), 0)] + t1);
		if (p2 > s) f[i] = min(f[i], f[max(i - (p2 - s), 0)] + t2);
		f[i] = min(f[i], f[max(i - (p1 + p2 - s), 0)] + max(t1, t2));
	}
	printf("%lld\n", f[h]);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#ifdef LOCAL
template<class t,class u>ostream& operator<<(ostream& os,const pair<t,u>& p){return os<<"("<<p.first<<","<<p.second<<")";}
#endif
template<class t>ostream& operator<<(ostream& os,const vector<t>& v){if(v.size())os<<v[0];for(int i=1; i<v.size(); i++)os<<' '<<v[i]; return os;}
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3;
ll n, m, t, k, a, b, c, d, cnt, mark, an, oT_To, x, y, z;
ll ans;

struct Solver {
	void solve() {
        cin >> a >> b >> c >> d >> n >> m;
        if (b > d) {
            swap(a, c);
            swap(b, d);
        }
        //b < d
        a -= m;
        c += a;
        // cost b dam a
        // cost d dam c
//        cout << "a: " << a << '\n';
//        cout << "b: " << b << '\n';
//        cout << "c: " << c << '\n';
//        cout << "d: " << d << '\n';
        vector <ll> dp (10005, INF);
//        cout << "INF: " << INF << '\n';
        dp[0] = 0;
        vector <pair<ll, ll> > ve;
        ve.push_back({a, b});
        ve.push_back({c, d});
        ll nd = a, nc = b;
        while (nd < n) {
            nd <<= 1;
            nc <<= 1;
            ve.push_back({nd, nc});
        }
        nd = c, nc = d;
        while (nd < n) {
            nd <<= 1;
            nc <<= 1;
            ve.push_back({nd, nc});
        }

        for (auto p : ve) {
            for (int i = 5000; i >= 0; i--) {
                dp[i+p.first] = min(dp[i+p.first], dp[i] + p.second);
            }
        }
        ans = dp[n];
//        for (int i = 0; i <= n*2; ++i) {
//            cout << dp[i] << '\n';
//        }
        for (int i = n; i <= 10000; ++i) {
            ans = min(ans, dp[i]);
        }
        cout << ans << '\n';

	}
};

int main () {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    oT_To = 1;
//    cin >> oT_To;
    while (oT_To--) {
    	Solver solver;
        solver.solve();
    }
}

#include <bits/stdc++.h>
// #include "atcoder/all"
// using namespace atcoder;
using namespace std;
using ll = long long;
const int MOD1000000007 = 1000000007;
const int MOD998244353 = 998244353;
const double PI = 3.14159265358979323846264338327950288;

void solve();
int main()
{

#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    solve();
#ifdef LOCAL
    printf("\nTime elapsed: %.2fs.\n", 1.0 * clock() / CLOCKS_PER_SEC);
#endif
    return 0;
}

void solve()
{
    ll p1, p2, h, s;
    ll t1, t2;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
    auto query = [&](ll ch)
    {
        ll l = 0, r = 1e18;
        while (l < r)
        {
            ll mid = (l + r) / 2;
            if ((mid / t1) * (p1 - s) + (mid / t2) * (p2 - s) < ch)
                l = mid + 1;
            else
                r = mid;
        }
        return l;
    };
    ll ans = 1e18;
    for (int i = 0; i < 5005; i++)
    {
        if ((p1 + p2 - s) * i >= h)
        {
            ans = min(ans, i * max(t1, t2));
            break;
        }
        else
        {
            ans = min(ans, i * max(t1, t2) + query(h - (p1 + p2 - s) * i));
        }
    }
    cout << ans << endl;
}

#include <algorithm>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <utility>
#include <limits.h>
#include <climits>
#include <numeric>
#include <map>
#include <unordered_map>
#include <cfloat>
#include <queue>
#define ll long long int
#define DEBUG false
using namespace std;

void debug(string s) {
    if (DEBUG) cout << s << endl;
}

void debug(int s) {
    if (DEBUG) cout << s << endl;
}

void debug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}

//flat debug of vector of vectors
void fdebug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j];
            if (j != v[i].size() - 1) {
                cout << " ";
            }
        }
        cout << "; ";
    }
    cout << endl;
}

void debug(vector<ll> & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        cout << v[i] << " ";
    }
    cout << endl;
}

ll MX = 1.e16;

class Solution {
    ll p1, t1, p2, t2, h, s;
public:
    void init() {
        cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

        if (DEBUG) {
            MX = 1.e16;
        }

    }

    ll solve() {
        init();
        if (t1 == t2) {
            ll res = (h + p1 + p2 - s - 1) / (p1 + p2 - s) * t1;
            return res;
        }

        // minimum time to cut at least i energy and shoot two guns at last
        vector<ll> dp(h + 1, MX);
        dp[0] = 0;
        ll first(0), second(0);
        ll e(0), t(0); // energy and time killed so far
        while (true) {
            // this happens only first time
            if ((first == 0) and (second == 0)) {
                if (t1 < t2) {
                    first = 0;
                    second = t1;
                    e += p1 - s;
                    t = t1;
                } else {
                    second = 0;
                    first = t2;
                    e += p2 - s;
                    t = t2;
                }
            } else { // either first == 0 or second == 0
                // shoot first
                if (first == 0) {
                    // wait
                    ll ew = e + p2;
                    ll tw = t + t2 - second;
                    if (ew <= h) {
                        dp[ew] = min(dp[ew], tw);
                    } else {
                        dp[h] = min(dp[h], tw);
                    }
                    // shoot the cheapest
                }
                if (second == 0) {
                    // wait
                    ll ew = e + p1;
                    ll tw = t + t1 - first;
                    if (ew <= h) {
                        dp[ew] = min(dp[ew], tw);
                    } else {
                        dp[h] = min(dp[h], tw);
                    }
                    // shoot the cheapest
                }
                // shoot the cheapest
                if (t1 - first == t2 - second) {
                    e += p1 + p2 - s;
                    t += t1 - first;
                    first = 0;
                    second = 0;
                } else if (t1 - first < t2 - second) {
                    e += p1 - s;
                    t += t1 - first;
                    second += t1 - first;
                    first = 0;
                } else {
                    e += p2 - s;
                    t += t2 - second;
                    first += t2 - second;
                    second = 0;
                }
            }
            if (DEBUG) {
                cout << e << " " << t << " " << first << " " << second << endl;
            }
            if (e >= h) {
                dp[h] = min(dp[h], t);
                break;
            }
            if ((first == 0) and (second == 0)) {
                dp[e] = min(dp[e], t);
                break;
            }
        }

        debug(dp);

        debug(dp);

        // update
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; 2 * j <= i; ++j) {
                dp[i] = min(dp[i], dp[j] + dp[i - j]);
            }
        }

        //
        for (int i = h - 1; i >= 0; --i) {
            dp[i] = min(dp[i], dp[i + 1]);
        }

        debug(dp);

        // update general
        first = 0;
        second = 0;
        e = 0;
        t = 0;
        ll res(dp[h]);
        while (e < h) {
            // shoot first
            if (t1 - first < t2 - second) {
                e += p1 - s;
                t += t1 - first;
                second += t1 - first;
                first = 0;
                if (e >= h) {
                    res = min(res, t);
                } else {
                    res = min(res, t + dp[h - e]);
                }
            } else if (t2 - second < t1 - first) {
                e += p2 - s;
                t += t2 - second;
                first += t2 - second;
                second = 0;
                if (e >= h) {
                    res = min(res, t);
                } else {
                    res = min(res, t + dp[h - e]);
                }
            } else {
                break;
            }
            if (DEBUG) {
                cout << " " << e << " " << t << " " << dp[h - e] << " " << res << endl;
            }
        }

        return res;

        /*priority_queue<vector<ll>, vector<vector<ll>>, greater<vector<ll>>> q;
        //vector<ll> d;  // distance
        vector<ll> v = {0, 0, 0, 0};  // distance, t1, t2, energy reduction
        //d.push_back(0);
        q.push(v);

        while (!q.empty()) {
            vector<ll> v = q.top();
            q.pop();
            if (v[3] >= h) return v[0];
            // else
            if ((v[1] == t1) and (v[2] == t2)) {
                // shoot both if can
                ll e = v[3] + p1 + p2 - s;
                vector<ll> w = {v[0], 0, 0, e};
                q.push(w);
            } else if (v[1] == t1) {
                // shoot first
                ll e = v[3] + (p1 - s);
                vector<ll> w = {v[0], 0, v[2], e};
                q.push(w);
                // or wait
                w = {v[0] + t2 - v[2], t1, t2, v[3]};
                q.push(w);
            } else if (v[2] == t2) {
                // shoot second
                ll e = v[3] + (p2 - s);
                vector<ll> w = {v[0], v[1], 0, e};
                q.push(w);
                // or wait
                w = {v[0] + t1 - v[1], t1, t2, v[3]};
                q.push(w);
            } else {
                if (t1 - v[1] < t2 - v[2]) {
                    vector<ll> w = {v[0] + t1 - v[1], t1, v[2] + t1 - v[1], v[3]};
                    q.push(w);
                } else {
                    vector<ll> w = {v[0] + t2 - v[2], v[1] + t2 - v[2], t2, v[3]};
                    q.push(w);
                }
            }
        } */

        //return 0;
    }

};

int main()
{
    int n = 1;
    //cin >> n;
    Solution sol;
    for(int i = 1; i != n + 1; ++i) {
        cout << fixed << setprecision(0) << sol.solve() << "\n";
    }

    return 0;
}

# include <bits/stdc++.h>
# define pb push_back
# define eb emplace_back
# define f first
# define s second
# define int long long
using namespace std;
set <pair <int,int>> dp[3][5001];
main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long p[3], t[3];
    long long h, S;
    cin >> p[1] >> t[1];
    cin >> p[2] >> t[2];
    cin >> h >> S;
    set <pair <pair <int,int>,pair <int,int>>> event;
    event.insert({{t[1],h},{1,0}});
    event.insert({{t[2],h},{2,0}});
    pair <pair <int,int>,pair <int,int>> state[3][5001], val, val2, i;
    bool timeline[3][5001];
    int op[3];
    op[2] = op[1] = 5001;
    int cnt = 0;
    while(1){
        cnt ++;
        // if(cnt > 20){
        //     return -1;
        // }
        i = *event.begin();
        event.erase(i);
        // cout << i.f.f << ' ' << i.f.s << ' ' << i.s.f << ' ' << i.s.s << endl;
        val = {{i.f.f + t[i.s.f],i.f.s},{i.s.f, i.s.s + p[i.s.f] - S}};
        if(i.f.s <= i.s.s + p[i.s.f] - S){
            cout << i.f.f << endl;
                return 0;
        }
        bool effective = true;
        if(state[3^i.s.f][i.f.s].f.f != 0){
            val2 = state[3^i.s.f][i.f.s];
            int damage = i.s.s + val2.s.s + p[i.s.f];
            if(i.f.s <= i.s.s + val2.s.s + p[i.s.f]){
                // cout << i.f.f << ' ' << val2.s.s << ' ' << i.f.s << endl;
                cout << i.f.f << endl;
                return 0;
            }
            if(i.f.s - damage > op[i.s.f]) effective = false;
            // cout << i.f.f << ' ' << i.f.s << ' ' << op[i.s.f] << endl;
            if(effective){
                event.insert({{i.f.f + t[1],i.f.s - damage},{1, 0}});
                event.insert({{i.f.f + t[2],i.f.s - damage},{2, 0}});
                timeline[1][i.f.s - damage] = 1;
                timeline[2][i.f.s - damage] = 1;
            }
        }
        op[i.s.f] = min(op[i.s.f], val.f.s - val.s.s - state[3^i.s.f][i.f.s].s.s + 2);
        timeline[i.s.f][i.f.s] = effective;
        if(effective || !effective && timeline[3^i.s.f][i.f.s]){
        event.insert(val);
        state[i.s.f][i.f.s] = val;
        }
    }
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

ll p1, t1, p2, t2, H, S;

ll solve(ll hp) {
	ll lo = min(t1, t2), hi = 4e18;
	while (lo + 1 < hi) {
		ll mid = (lo + hi) / 2;
		ll dmg = mid / t1 * max(p1 - S, 0LL) + mid / t2 * max(p2 - S, 0LL);
		if (dmg >= hp) {
			hi = mid;
		} else {
			lo = mid;
		}
	}
	return hi;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> p1 >> t1 >> p2 >> t2 >> H >> S;
	if (t1 > t2) {
		swap(p1, p2);
		swap(t1, t2);
	}
	ll ans = 4e18;
	for (int i = 0; i <= H; ++i) {
		ll dmg = i * ((p1 + p2 - S) + (t2 - t1) / t1 * max(p1 - S, 0LL));
		ll time = i * t2;
		ll hp = H - dmg;
		if (hp <= 0) {
			ans = min(ans, time);
			break;
		}
		ans = min(ans, time + solve(hp));
	}
	cout << ans << "\n";
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MOD=1e9+7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int p1,p2,h,s;
	long long t1,t2;
	cin>>p1>>t1>>p2>>t2>>h>>s;

	long long ans=1e18;

	for(int u=0; u<=h; u++){
		long long tb=u*max(t1,t2);

		for(int v=0; v<=h; v++){
			if(u*(p1+p2-s)+v*(p1-s)<h) continue;
			long long b=t1<t2 && u?t2/t1-1:0;
			if(b<=v){
				ans=min(ans, tb+(v-b)*t1);
			}
			else{
				ans=min(ans,tb);
			}

		}

		for(int w=0; w<=h; w++){
			if(u*(p1+p2-s)+w*(p2-s)<h) continue;
			long long b=t2<t1 && w?t1/t2-1:0;
			if(b<=w){
				ans=min(ans, tb+(w-b)*t2);
			}
			else{
				ans=min(ans,tb);
			}
		}

	}
	cout<<ans;

    return 0;
}

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

#define rep(i, a, n) for(int i=(a); i<(n); ++i)
#define per(i, a, n) for(int i=(a); i>(n); --i)
#define pb emplace_back
#define mp make_pair
#define clr(a, b) memset(a, b, sizeof(a))
#define all(x) (x).begin(),(x).end()
#define lowbit(x) (x & -x)
#define fi first
#define se second
#define lson o<<1
#define rson o<<1|1
#define gmid l[o]+r[o]>>1

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;

constexpr int mod = 998244353;
constexpr int inf = 0x3f3f3f3f;
constexpr int N = 5010;

int p1, p2, h, s;
ll t1, t2, dp[N];

void upd(ll &x, ll y){
  if(x == -1 || x > y)  x = y;
}

void _main(){
  cin >> p1 >> t1;
  cin >> p2 >> t2;
  cin >> h >> s;

  clr(dp, -1);
  dp[0] = 0;
  ll v1 = t1, v2 = t2;
  int c = 0;
  while(c < h){
    ll cur = min(v1, v2);
    if(v1 == v2){
      c = c + (p1 + p2 - s);
      v1 += t1;
      v2 += t2;
    } else if(v1 < v2){
      c = c + (p1 - s);
      v1 += t1;
    } else {
      c = c + (p2 - s);
      v2 += t2;
    }
    if(c > h) c = h;
    upd(dp[c], cur);
  }

  ll ans = dp[h];
  rep(i, 1, h + 1){
    rep(j, 1, h + 1){
      ll t = max(i * t1, j * t2);
      int d = (i - 1) * (p1 - s) + (j - 1) * (p2 - s) + (p1 + p2 - s);
      upd(dp[min(h, d)], t);
    }
  }

  per(i, h-1, -1) upd(dp[i], dp[i+1]);

  rep(i, 1, h){
    upd(ans, dp[i] * (h / i) + dp[h % i]);
  }

  cout << ans << '\n';
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  _main();
  return 0;
}

// Author: kyEEcccccc

#include <bits/stdc++.h>

using namespace std;

using LL = long long;
using ULL = unsigned long long;

const int H = 5005;
const LL INF = 5000000000000000LL;

LL bf[H], mnti[H], f[H];

int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);

    int p1, p2, h, s;
    LL t1, t2;
    cin >> p1 >> t1;
    cin >> p2 >> t2;
    cin >> h >> s;

    int d1 = p1-s, d2 = p2-s, dd = p1+p2-s;
    for (int i = 1; i <= h; ++i)
    {
        LL lp = 1, rp = INF;
        bf[i] = INF;
        while (lp <= rp)
        {
            LL mid = (lp + rp) / 2;
            if ((mid / t1) * d1 + (mid / t2) * d2 >= i)
            {
                rp = mid - 1;
                bf[i] = mid;
            }
            else lp = mid + 1;
        }
    }

    mnti[0] = 0;
    for (int i = 1; i <= h; ++i) mnti[i] = INF;
    for (int i = 0; i <= h / d1; ++i)
    {
        LL tti = t1 * i;
        if (tti < t2) continue;
        LL n2 = tti / t2 - 1;
        LL tdmg = i * d1 + n2 * d2 + dd;
        mnti[min(tdmg, 1LL*h)] = min(mnti[min(tdmg, 1LL*h)], tti);
    }
    for (int i = 0; i <= h / d2; ++i)
    {
        LL tti = t2 * i;
        if (tti < t1) continue;
        LL n1 = tti / t1 - 1;
        LL tdmg = i * d2 + n1 * d1 + dd;
        mnti[min(tdmg, 1LL*h)] = min(mnti[min(tdmg, 1LL*h)], tti);
    }

    for (int i = 1; i <= h; ++i)
        for (int j = 1; j <= i-j; ++j)
            mnti[i] = min(mnti[i], mnti[j]+mnti[i-j]);
    LL ans = INF;
    for (int i = 0; i <= h; ++i)
        ans = min(ans, mnti[i] + bf[h-i]);
    cout << ans << '\n';

    return 0;
}

#include<bits/stdc++.h>
#define lowbit(x) x&(-x)
#define int long long
using namespace std;
const int N=3e5+5,mod=998244353;
int n,m,q;
int a[N],b[N],c[N];
inline int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}
struct data{
	int x,y;
	bool operator <(const data &t)const{
		return x>t.x;
	}
}d[N];
inline int qpow(int x,int y){
	int sum=1;
	while(y){
		if(y&1)sum=sum*x;
		y>>=1,x=x*x;
	}
	return sum;
}
int g[5005],f[5005];
signed main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int p1,t1,p2,t2,h,s;
	cin>>p1>>t1>>p2>>t2>>h>>s;
	for(int i=0;i<=h;++i)
		for(int j=0;j<=h;++j){
		int t=i*p1+j*p2-(i+j)*s;
		f[min(t,h)]=min(f[min(t,h)],max(t1*i,t2*j));
		if(t<=h)g[t]=min(g[t],max(t1*(i+1),t2*(j+1)));
		else break;
	}
	f[0]=0;
	int ans=1e18;
	for(int i=0;i<h;++i){
		for(int j=0;j<=h;++j){
			int t=min(h,i+j+p1+p2-s);
			f[t]=min(f[t],f[i]+g[j]);
			ans=min(ans,f[t]);
		}
	}
	cout<<f[h];
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define dbg(a) cout << #a << " = " << a << "\n"
#define dbg1(a) cout << #a << " = [ "; for (auto& _ : a) cout << _ << " "; cout << "]\n"
#define dbg2(a) cout << #a << " = [ "; for (auto& _ : a) cout << "(" << _.first << " " << _.second << ") "; cout << "]\n"
#define fastIo(a) ios_base::sync_with_stdio(a); cin.tie(a); cout.tie(a)

using ll = long long;
using ld = long double;
const double Pi = 3.14159265;

const int INF = 2e9;
const ll INFll = 2e18;
const double EPS = 1e-8;

mt19937 rnd(time(0));

#define int long long

void solve() {
    int p1, t1, p2, t2, h, s;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
    vector<int> dp(h + 1, INFll);
    dp[h] = max(t1, t2);
    ll ans = INFll;

    int l1 = -1, r1 = 1e18;
    while (l1 + 1 < r1){
        int m = (l1 + r1) / 2;
        if ((m / t1) * (p1 - s) + (m / t2) * (p2 - s) >= h) r1 = m;
        else l1 = m;
    }
    ans = r1;

    for (int i = h; i >= 0; i--){
        for (int j = h; j > i; j--){ // сколько хп было последний раз, когда стреляли оба
            int h1 = (j - p1 - p2 + s);
            int l = -1, r = 1e18;
            while (l + 1 < r){
                int m = (l + r) / 2;
                if (h1 - i < 0) {
                    r = max(t1, t2);
                    l = r - 1;
                    continue;
                }
                if ((m / t1 - 1) < 0 || (m / t2 - 1) < 0) {
                    l = m;
                    continue;
                }
                if ((m / t1 - 1) * (p1 - s) + (m / t2 - 1) * (p2 - s) >= (h1 - i)) r = m;
                else l = m;
            }

            l1 = -1, r1 = 1e18;
            while (l1 + 1 < r1){
                int m = (l1 + r1) / 2;
                if ((m / t1) * (p1 - s) + (m / t2) * (p2 - s) >= h1) r1 = m;
                else l1 = m;
            }
            ans = min(ans, dp[j] + r1);

            dp[i] = min(dp[i], dp[j] + r);
        }
        if (i - p1 - p2 + s <= 0){
            ans = min(ans, dp[i]);
        }
    }
    cout << ans;

}

signed main() {
    fastIo(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define uint unsigned long long

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
const int N = 6000;
const int INF = 1e18;
const int M = 998244353;
const ld EPS = 1e-6;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt = 1;
    while (tt--) {
        int p1, t1;
        int p2, t2;
        cin >> p1 >> t1;
        cin >> p2 >> t2;
        if (t1 > t2) {
            swap(t1,t2);
            swap(p1,p2);
        }
        int h,s;
        cin >> h >> s;
        vector<int> dp(h + 1, INF);
        dp[0] = 0;
        int ans = INF;
        vector<int> muls;
        for (int i = 0; i <= N; ++i) {

            muls.push_back(i * t1);
            muls.push_back(i * t2);
        }
        sort(all(muls));
        for (int d = 0; d <= h; ++d) {
            for (auto t : muls) {
                int col1 = t / t1 - 1;
                int col2 = t / t2 - 1;
                if (col2 < 0) {
                    int D = (col1 + 1) * (p1 - s);
                    if (D >= h) {
                        ans = min(ans, dp[d] + t);
                    }
                } else {
                    int D = col1 * (p1 - s) + col2 * (p1 - s) + (p1 + p2 - s);
                    if (d + D > h) {
                        ans = min(ans, dp[d] + t);
                    } else {
                        dp[D + d] = min(dp[D + d], dp[d] + t) ;
                    }
                }

            }
        }
        cout << min(ans, dp[h]) << endl;

    }
}
// 00000000101
// we cant remove 1
// we cant concat 1
// we can move 1
// we can add 1 near 1
//01111100000
//12383305831528
//19563725075771

//1110010

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define uint unsigned long long

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
const int N = 4000;
const int INF = 1e18;
const int M = 998244353;
const ld EPS = 1e-6;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt = 1;
    while (tt--) {
        int p1, t1;
        int p2, t2;
        cin >> p1 >> t1;
        cin >> p2 >> t2;
        if (t1 > t2) {
            swap(t1,t2);
            swap(p1,p2);
        }
        int h,s;
        cin >> h >> s;
        vector<int> dp(h + 1, INF);
        dp[0] = 0;
        int ans = INF;
        vector<int> muls;
        for (int i = 0; i <= N; ++i) {
            muls.push_back(i * t1);
            muls.push_back(i * t2);
        }
        sort(all(muls));
        for (int d = 0; d <= h; ++d) {
            for (auto t : muls) {
                int col1 = t / t1 - 1;
                int col2 = t / t2 - 1;
                if (col2 < 0) {
                    int D = (col1 + 1) * (p1 - s);
                    if (D >= h) {
                        ans = min(ans, dp[d] + t);
                    }
                } else {
                    uint D = col1 * (p1 - s) + col2 * (p2 - s) + (p1 + p2 - s);
                    if (d + D > h) {
                        ans = min(ans, dp[d] + t);
                    } else {
                        dp[D + d] = min(dp[D + d], dp[d] + t) ;
                    }
                }

            }
        }
        cout << min(ans, dp[h]) << endl;

    }
}
// 00000000101
// we cant remove 1
// we cant concat 1
// we can move 1
// we can add 1 near 1
//01111100000
//12383305831528
//19563725075771

//1110010

#include <bits/stdc++.h>

#define int long long

using namespace std;

typedef long long ll;
typedef long double ld;

#define pii pair<int, int>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

int32_t main() {
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int p1, t1, p2, t2, h, s;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

    set<int> t;

    for (int i = 1; i <= h; i++) {
        t.insert(t1 * i);
        t.insert(t2 * i);
    }

    vector<int> dp(h + 1, LLONG_MAX);
    dp[0] = 0;

    for (int i = 1; i <= h; i++) {
        for (int x : t) {
            if (x >= max(t1, t2)) {
                int damage = x / t1 * (p1 - s) + x / t2 * (p2 - s) + s;
                if (damage <= i) {
                    if (dp[i - damage] < LLONG_MAX) {
                        dp[i] = min(dp[i], dp[i - damage] + x);
                    }
                }
                if (damage >= h) {
                    dp[h] = min(dp[h], x);
                    break;
                }
            }
        }
    }

    vector<int> d(h + 1, LLONG_MAX);
    d[0] = 0;

    for (int x : t) {
        int damage = x / t1 * (p1 - s) + x / t2 * (p2 - s);
        d[min(h, damage)] = min(d[min(h, damage)], x);
    }
    for (int i = h - 1; i >= 1; i--) {
        d[i] = min(d[i], d[i + 1]);
    }

    int ans = LLONG_MAX;

    for (int i = 0; i <= h; i++) {
        if (dp[i] < LLONG_MAX && d[h - i] < LLONG_MAX) {
            ans = min(ans, dp[i] + d[h - i]);
        }
    }

    cout << ans;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int MAX_N = 5e3 + 1;
const ll MAX_LL = 9223372036854775807ll;

struct NODE{
	ll wait, cost;
	NODE (ll w = 0, ll c = 0) {wait = w; cost = c;}
	bool operator < (const NODE &b) const {
		if (cost == b.cost) return wait > b.wait;
		else return cost < b.cost;
	}
}f[MAX_N][4];

int n, h, s;
int p[5], t[5];

int main() {
	scanf("%d%d", &p[1], &t[1]);
	scanf("%d%d", &p[2], &t[2]);
	scanf("%d%d", &h, &s);
	for (int i = 0; i <= h; ++i) {
		f[i][1].cost = f[i][2].cost = MAX_LL;
	}
	f[h][1].cost = f[h][2].cost = 0;
	int dst = 0, cnt = 0;
	for (int i = h; i >= 1; --i) {
		for (int k = 1; k <= 2; ++k) {
			if (f[i][k].cost != MAX_LL) {
//				printf("f[%d][%d] = (%lld, %lld)\n", i, k, f[i][k].wait, f[i][k].cost);
				ll j = f[i][k].wait, c = f[i][k].cost;
				if (t[k] - j >= t[k ^ 3]) {
					dst = max(0, i - p[k ^ 3] + s);
					f[dst][k] = min(f[dst][k], NODE(j + t[k ^ 3], c + t[k ^ 3]));

					cnt = (t[k] - j) / t[k ^ 3];
					dst = max(0, i - p[k] - cnt * (p[k ^ 3] - s));
					f[dst][k] = min(f[dst][k], NODE(0, c + t[k] - j));
					f[dst][k ^ 3] = min(f[dst][k ^ 3], NODE(0, c + t[k] - j));
				} else {
					dst = max(0, i - p[k] + s);
					f[dst][k ^ 3] = min(f[dst][k ^ 3], NODE(t[k] - j, c + t[k] - j));

					cnt = (t[k ^ 3] - t[k] + j) / t[k] + 1;
					dst = max(0, i - cnt * (p[k] - s) - p[k ^ 3]);
					f[dst][k] = min(f[dst][k], NODE(0, c + t[k ^ 3]));
					f[dst][k ^ 3] = min(f[dst][k ^ 3], NODE(0, c + t[k ^ 3]));
				}
			}
//			if (f[i][1].cost != MAX_LL) {
//				printf("f[%d][1] = (%lld, %lld)\n", i, f[i][1].wait, f[i][1].cost);
//				int j = f[i][1].wait;
//				if (t[2] - j >= t[1]) {
//					dst = max(0, i - p[1] + s);
//					f[dst][1] = min(f[dst][1], f[i][1] + NODE(t[1], t[1]));
//					dst = max(0, i - p[1] - p[2] + s);
//					f[dst][0] = min(f[dst][0], f[i][1] + NODE(0, t[2] - j));
//					f[dst][1] = min(f[dst][1], f[i][1] + NODE(0, t[2] - j));
//				} else {
//					dst = max(0, i - p[2] + s);
//					f[dst][0] = min(f[dst][0], f[i][1] + NODE(t[2] - j, t[2] - j));
//					dst = max(0, i - p[1] - p[2] + s);
//					f[dst][0] = min(f[dst][0], f[i][1] + NODE(0, t[1]));
//					f[dst][1] = min(f[dst][1], f[i][1] + NODE(0, t[1]));
//				}
//			}
		}
	}
	ll ans = MAX_LL;
	ans = min(ans, min(f[0][1].cost, f[0][2].cost));
//	printf("%lld %lld\n", f[0][1].cost, f[0][2].cost);
	printf("%lld", ans);
	return 0;
}
/*
2 49
2 21
21 1
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef pair <int, int> pii;
#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cerr<<endl
template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
os<<"{"<<p.first<<","<<p.second<<"}";
return os;
}
template <class T , size_t N>
ostream &operator <<(ostream &os,const array <T,N> &a)
{
os<<"{";
for(auto x: a)
os<<x<<" ";
os<<"}";
return os;
}
#define getbit(n, i) (((n) & (1LL << (i))) != 0)
#define setbit0(n, i) ((n) & (~(1LL << (i))))
#define setbit1(n, i) ((n) | (1LL << (i)))
#define togglebit(n, i) ((n) ^ (1LL << (i)))
#define lastone(n) ((n) & (-(n)))
char gap = 32;
#define int long long
#define ll long long
#define lll __int128_t
#define pb push_back
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
int dp[5001];
int p1, p2, t1, t2;
int h, s;
int recurse(int life) {
    if(life <= 0) return 0;
    if(dp[life] != -1) return dp[life];
    int ans = LONG_LONG_MAX;
    for(int i = 0; i <= 5000; i++) {
        int temp = (t1 * i) / t2;
        int rem = life - (i * p1 + temp * p2 - (i + temp) * s);
        rem -= (p1 + p2 - s);
        int additional = max(t1, (temp + 1) * t2 - t1 * i);
        ans = min(ans, recurse(rem) + i * t1 + additional);
    }
    return dp[life] = ans;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> p1 >> t1 >> p2 >> t2;
    cin >> h >> s;
    memset(dp, -1, sizeof(dp));
    if(t1 > t2) {
        swap(t1, t2);
        swap(p1, p2);
    }
    int res = ((h + p1 - s - 1) / (p1 - s)) * t1;
    res = min(res, ((h + p2 - s - 1) / (p2 - s)) * t2);
    cout << min(res, recurse(h)) << "\n";
    return 0;
}

/*3 9
3 13
25 1*/

#include <bits/stdc++.h>
using namespace std;
#define close ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
typedef long long LL;
typedef pair<int, int> PII;
#define int LL
#define fi first
#define se second
inline int read() {
    int s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        s = (s << 1) + (s << 3) + (ch - '0');
        ch = getchar();
    }
    return s * w;
}
const int N = 5e3 + 5;
int p1, t1;
int p2, t2;
int h, s;
int f[N];
int Min(int x) {
    return min((LL)h, x);
}
void solve() {
    memset(f, 0x3f, sizeof(f));
    cin >> p1 >> t1;
    cin >> p2 >> t2;
    cin >> h >> s;
    if (t1 < t2) swap(p1, p2), swap(t1, t2);
    f[0] = 0;
    vector<PII> head;
    int k = t1 / t2;
    for (int i = 1; i <= k; i++) {
        head.push_back(PII(Min((p2 - s) * i), i * t2));
        if ((p2 - 1) * i >= h) break;
    }
    head.push_back(PII(Min(p1 + p2 - s + (k - s) * (p2 - s)), t1));
    if (t1 % t2) {
        head.push_back(PII(Min(p1 + p2 - s + k * (p2 - s)), (k + 1) * t2));
    }
//    for (auto [x, y]:head) cout << x << ' ' << y << endl;
//    cout << endl;
    int ans = 2e18;
    for (int i = 1; i <= 5000; i++){
        for (auto [x, y]:head) {
            if (i >= x) f[i] = min(f[i - x] + y, f[i]);
            if (i >= h) ans = min(ans, f[i]);
        }
    }
    cout << ans << endl;
}
signed main() {
    close;
    srand(time(0));
    int t = 1;
//    cin >> t;
    while (t--) solve();
    return 0;
}

/* Code Information
 * Author: SkqLiiiao
 * Time: 2022-10-18 09:02:36
 * Url:
 **/
#include <bits/stdc++.h>

using namespace std;

int main() {
    cin.tie(NULL)->sync_with_stdio(false);
    int p1, p2, h, s;
    long long t1, t2;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

    if (t1 > t2) {
        swap(p1, p2);
        swap(t1, t2);
    }

    long long l = 1, r = 1e18, ans = -1;

    auto cal = [&](int n, int m, long long t) {
        auto f = vector(m + 1, static_cast<long long>(1e18));

        for (int i = 0; i <= m; ++i)
            f[i] = t1 * i;

        for (int i = 1; i <= n; ++i) {
            long long mn = LLONG_MAX;

            for (int j = 0; j <= m; ++j)
                mn = min(mn, f[j]);

            if (mn > t)
                return false;

            auto g = vector(m + 1, static_cast<long long>(1e18));

            for (int j = 0; j <= m; ++j) {
                for (int k = j; k <= m; ++k) {
                    auto t = f[j] + max(t1 * (k - j + 1), t2);
                    g[k] = min(g[k], t);
                }
            }

            swap(f, g);
        }

        return f[m] <= t;
    };

    auto check = [&](long long t) {
        long long num = t / t2;
        long long left = h - num * (p1 + p2 - s);

        if (left <= 0)
            return true;

        int more = left / (p1 - s) + (bool)(left % (p1 - s));

        if (t1 * (more + num) > t)
            return false;

        return cal(num, more, t);
    };

    check(63);
    return 0;

    while (l <= r) {
        auto m = (l + r) / 2;

        if (check(m)) {
            ans = m;
            r = m - 1;
        } else
            l = m + 1;
    }

    cout << ans << endl;
    return 0;
}

#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <set>
#include <stack>
#include <array>
#include <bitset>
#include <chrono>
#define int ll
typedef long long ll;
using namespace std;
signed main() {
    int p1;
    ll t1;
    int p2;
    ll t2;
    cin >> p1 >>  t1 >> p2 >> t2;
    int h, s;
    cin >> h >> s;
    vector<pair<int, ll>> acts;
    {
        int ch = h;
        ll b1 = 0, b2 = 0;
        ll mm = 0;
        while (ch > 0) {
            {
                acts.emplace_back(h - max(ch - p1 - p2 + 1, 0LL),
                                  max(b1 + t1, b2 + t2));
            }
            if (b1 + t1 == b2 + t2) {
                mm = max(b1 + t1, b2 + t2);
                ch -= p1 + p2 - s;
                b1 = b2 = mm;
            } else {
                if (b1 + t1 < b2 + t2) {
                    mm = b1 + t1;
                    ch -= p1 - s;
                    b1 = mm;
                } else {
                    mm = b2 + t2;
                    ch -= p2 - s;
                    b2 = mm;
                }
            }
        }
    }
    vector<ll> dp(h + 1, t1 * 5000);
    dp[0] = 0;
    for (auto [dt, tm] : acts) {
        for (int i = 0; i + dt <= h; ++i) {
            dp[i + dt] = min(dp[i + dt], dp[i] + tm);
        }
    }
    ll ans = t1 * 5000;
    for (int j = 0; j <= h; ++j) {
        int ch = h - j;
        ll b1 = 0, b2 = 0;
        ll mm = 0;
        while (ch > 0) {
            if (b1 + t1 == b2 + t2) {
                mm = max(b1 + t1, b2 + t2);
                ch -= p1 + p2 - s;
                b1 = b2 = mm;
            } else {
                if (b1 + t1 < b2 + t2) {
                    mm = b1 + t1;
                    ch -= p1 - s;
                    b1 = mm;
                } else {
                    mm = b2 + t2;
                    ch -= p2 - s;
                    b2 = mm;
                }
            }
        }
        ans = min(ans, mm + dp[j]);
    }
    cout << ans;
    return 0;
}

#include <bits/stdc++.h>
#define NO {cout<<"NO"<<endl;return;}
#define YES {cout<<"YES"<<endl;return;}
#define debug(a) cout<<"debug: "<<(#a)<<" = "<<a<<'\n'
#define db cout<<"kale"<<endl;
#define PII pair<int,int>
#define int long long
#define fi first
#define se second
#define io ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
const int N = 5050;
int dp[N][N];

void solve()
{
	int p1,t1,p2,t2,h,s;
	cin>>p1>>t1>>p2>>t2>>h>>s;
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			dp[i][j]=1e16;

	dp[h][0]=0;
	if(t1>t2)swap(t1,t2),swap(p1,p2);
	int ans=1e16;

	for(int i=h;i>=0;i--)
		for(int j=5000;j>=0;j--)
		{
			int wait_time=(j*t1)%t2;
			wait_time=t2-wait_time;

			//一已经射出来了，现在射二
			if(wait_time<t1&&i<=p2-s)ans=min(ans,dp[i][j]+wait_time);

			if(t1<wait_time)
			{
				if(i<=p1-s)ans=min(ans,dp[i][j]+t1);
				else dp[i-p1+s][j+1]=min(dp[i-p1+s][j+1],dp[i][j]+t1);
			}

			//射2再射1;
			if(t1>wait_time&&i>p2-s)
			{
				if(i<=p1+p2-s-s)ans=min(ans,dp[i][j]+t1);
				else dp[i-p1-p2+s+s][j+1]=min(dp[i-p1-p2+s+s][j+1],dp[i][j]+t2);
			}

			if(i<=p1+p2-s)ans=min(ans,dp[i][j]+max(t2,wait_time));
			else dp[i-p1-p2+s][0]=min(dp[i-p1-p2+s][0],dp[i][j]+max(t2,wait_time));
		}
	cout<<ans<<endl;
}

signed main()
{
	io;
	int T=1;
	//cin>>T;
	while(T--)
		solve();
	return 0;
}

#include <bits/stdc++.h>
//Constant
const long long H=5000;
const long long D=H*2;
//Read
long long Read(){
	long long x=0;
	bool neg=false;
	char c=getchar();
	while(isdigit(c)==false)neg^=c=='-',c=getchar();
	while(isdigit(c)==true)x=x*10+c-'0',c=getchar();
	return neg==true?-x:x;
}
//Main
long long p[H+1],f[D+1];
long long GCD(long long a,long long b){return a==0?b:GCD(b%a,a);}
int main(){
	long long p1=Read(),t1=Read();
	long long p2=Read(),t2=Read();
	if(t1<t2)std::swap(t1,t2),std::swap(p1,p2);
	long long h=Read(),s=Read(),lcm=t1*t2/GCD(t1,t2),n;
	for(long long i=1;i<=h;++i){
		p[i]=i*(p1-s)+i*t1/t2*(p2-s)+i*t1/lcm*s;
		if(i*t1%lcm!=0)p[i]+=s;
		for(long long j=1;j<=i/2;++j)p[i]=std::max(p[i],p[i-j]+p[j]);
		if(p[i]>=h){
			n=i;
			break;
		}
	}
	long long ans=n*t1;
	f[0]=0;
	for(long long i=1;i<=2*h;++i)f[i]=LLONG_MAX>>1;
	for(long long i=1;i<=n;++i)
		for(long long j=p[i];j<=2*h;++j)f[j]=std::min(f[j],f[j-p[i]]+i*t1);
	for(long long i=0;i<h;++i){
		long long l=1,r=(h-i)/(p2-s)+1,rest;
		while(l<=r){
			long long mid=l+r>>1;
			if(i+mid*(p2-s)+mid*t2/t1*(p1-s)+mid*t2/lcm*s>=h)rest=mid,r=mid-1;
			else l=mid+1;
		}
		ans=std::min(ans,f[i]+rest*t2);
	}
	for(long long i=h;i<=2*h;++i)ans=std::min(ans,f[i]);
	printf("%lld\n",ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ull = unsigned long long;
using ll = long long;
#define endl '\n'
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int maxn = 2e5 + 10;
const int mod = 1000000007;
#define inl inline
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define ford(i, a, b) for (int i = a; i >= b; i--)
#define forall(i, a) for (auto &i : a)
istream &operator>>(istream &in, vector<int> &v)
{
    for (auto &i : v)
        in >> i;
    return in;
}
ostream &operator<<(ostream &out, vector<int> &v)
{
    for (auto &i : v)
        out << i << " ";
    return out;
}

#define int ll
const int INF = 1e17;
// int lcm(int a, int b)
// {
//     return a * b / __gcd(a, b);
// }
void solve()
{
    int p[2];
    int t[2];
    cin >> p[0] >> t[0];
    cin >> p[1] >> t[1];
    int h, s;
    cin >> h >> s;
    int dp[5050];
    fr(i, 1, h)
        dp[i] = INF;
    dp[0] = 0;
    fr(i, 0, h - 1)
    {
        dp[min(h, i + (p[0] - s))] = min(dp[min(h, i + (p[0] - s))], dp[i] + t[0]);
        // if(!i)cout<<dp[1]<<endl;
        dp[min(h, i + (p[1] - s))] = min(dp[min(h, i + (p[1] - s))], dp[i] + t[1]);
        dp[min(h, i + p[0] + p[1] - s)] = min(dp[min(h, i + p[0] + p[1] - s)], dp[i] + max(t[0], t[1]));
    }
    // fr(i,1,h)
    // {
    //     cout<<i<<" ";
    //     cout<<dp[i]<<"\n";
    // }
    cout << dp[h] << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=5e3+10;
ll p1,t1,p2,t2,h,s;
ll f[N],dp[N];
void lulu_solution()
{
    ll res=1e18;
    cin >> p1 >> t1 >> p2 >>t2 >> h >> s;
    for (ll i=1;i<=h;i++) f[i]=1e18;
    for (ll i=1;i<=h;i++) dp[i]=1e18;
    for (int i=1 ;(p1-s)*i<=h;i++)
    {
        ll cost=i*t1;
        ll val=min(h,(p1-s)*i+(i*t1/t2)*(p2-s)+(i*t1/t2>0)*s);
        f[val]=min(f[val],cost);
     //   cout << i << " " <<val << "\n";
    }
    for (int i=1 ;(p2-s)*i<=h;i++)
    {
        ll cost=i*t2;
        ll val=min(h,(p2-s)*i+(i*t2/t1)*(p1-s)+(i*t2/t1>0)*s);
        f[val]=min(f[val],cost);
     //   cout << i << " " <<val << "\n";
    }
    for (ll i=1;i<=h;i++)
    {
        for (ll j=1;j<=i;j++)
        {
            dp[i]=min(dp[i],dp[i-j]+f[j]);
        }
    }
   // cout << dp[8] << " " <<dp[16];
    for (ll i=1;i<=h;i++)
    {
        ll l=0,r=1e18;
        while (l<r)
        {
            ll mid=(l+r)/2;
            if (mid/t1*(p1-s)+mid/t2*(p2-s)>=h-i) r=mid;
            else l=mid+1;
        }
        res=min(res,dp[i]+l);
      //  cout <<i << " " << dp[i] << " " << l << "\n";
    }
    cout << res;

}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    lulu_solution();
}

#include<bits/stdc++.h>
using namespace std;
#define int __int128_t
#define f(i, a, b) for(int i = (a); i <= (b); i++)
#define cl(i, n) i.clear(),i.resize(n);
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int inf = 1e9;
ll p1,t1,p2,t2,h,s;
int lcm(int x,int y){
    int gcd=__gcd(x,y);
    return x*y/gcd;
}
void print(int x){
    string ss;
    while(x){
        ss+=char((x%10)+'0');
        x/=10;
    }
    reverse(ss.begin(),ss.end());
    cout<<ss<<endl;
}
int calc(int t){
    int ret=0;
 //   int l=lcm(t1,t2);
 //   print(l);
 //   int k=t-(t/l)*l, tms = t/l;
 //   int k1=l/t1, k2=l/t2;
   // int dm=0;
  //  if(t2*s<t2*p1-t1*p1)dm=k2*p1+k2*p2-k2*s;
  //  else dm=k1*p1-k1*s+k2*p2-k2*s;
 //   ret+=dm*tms;
 //   t=k;
    int mx=0, tmp=0;
    int tp1=t/t1,tp2=t/t2;
    //第一种情况
    tmp=tp2*(p1+p2-s);
    mx=max(mx,tmp);
    //fenkaida
    tmp=tp1*(p1-s)+tp2*(p2-s);
    mx=max(mx,tmp);
    //第二种
    int t2tp1 = (tp2*t2)/t1;
    int t1mtp1 = (t-tp2*t2)/t1;
    tmp=0;
    if(tp2==0){

    }
    else {
        int t2m1tp1 = ((tp2-1)*t2)/t1;
        tmp=t2m1tp1*(p1-s)+(tp2-1)*(p2-s)+(p1+p2-s);

        tmp+=t1mtp1*(p1-s);
    }
    mx=max(mx,tmp);
    //
    tmp=0;
    tmp=tp2*(p1+p2-s);
    tmp+=t1mtp1*(p1-s);
    mx=max(mx,tmp);
    return ret + mx;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    time_t start = clock();
    //think twice,code once.
    //think once,debug forever.
    cin>>p1>>t1>>p2>>t2>>h>>s;
    if(t1>t2){
        swap(p1,p2);swap(t1,t2);
    }
    int l=0,r=(max(p1,p2)*max(t1,t2));
    while(l<r){
        int mid=(l+r)>>1;
        if(calc(mid)>=h)r=mid;
        else l=mid+1;
    }
    ll tt = l;
    cout<<tt<<endl;
    time_t finish = clock();
    //cout << "time used:" << (finish-start) * 1.0 / CLOCKS_PER_SEC <<"s"<< endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <iomanip>
#include <sstream>
using namespace std;
#define FIO ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
const ll inf = ll(1e9) + 7;

int main()
{
	FIO
		ll p1, p2, t1, t2, h, s;
	cin >> p1 >> t1;
	cin >> p2 >> t2;
	cin >> h >> s;
	vector<ll>dp(5001, 1e18);
	vector<ll>dp2(5001, 1e18);

	dp[0] = 0;
	dp2[0] = 0;
	for (ll i = 1; i <= 5000; ++i)
	{

		for (ll j = 1; j <= 5000; ++j)
		{
			ll t = j*t1;
			ll cnt1 = t / t1 - 1;
			ll cnt2 = t / t2 - 1;

			ll x = (t / t1) * (p1 - s) + (t / t2) * (p2 - s);

			if (x <= 5000&& x >= 0)
			{
				dp2[x] = min(dp2[x], t);
			}
			if (cnt1 < 0 || cnt2 < 0)continue;
			ll y = i - cnt1 * (p1 - s) - cnt2 * (p2 - s) - p1 - p2 + s;
			if (y < 0 || y > 5000)continue;
			dp[i] = min(dp[i], dp[y] + t);
		}
		for (ll j = 1; j <= 5000; ++j)
		{
			ll t = j*t2;
			ll cnt1 = t / t1 - 1;
			ll cnt2 = t / t2 - 1;

			ll x = (t / t1) * (p1 - s) + (t / t2) * (p2 - s);

			if (x <= 5000 && x>=0)
			{
				dp2[x] = min(dp2[x], t);
			}
			if (cnt1 < 0 || cnt2 < 0)continue;
			ll y = i - cnt1 * (p1 - s) - cnt2 * (p2 - s) - p1 - p2 + s;
			if (y < 0 || y > 5000)continue;
			dp[i] = min(dp[i], dp[y] + t);
		}

	}
	ll res = 1e18;
	for(ll i = 0; i<=5000;++i)
		for (ll j = 0; j <= 5000; ++j)
		{
			if (i + j < h)continue;
			res = min(res, dp[i] + dp2[j]);
		}

	cout << res;
		return 0;
}

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

const int maxn = 200005;

long long f[maxn];
int p1, p2, s, h;
long long t1, t2;

void solve() {
    for (int i=0;i<=h;++i) f[i] = 0x3f3f3f3f3f3f3f3f;
    f[0] = 0;
    for (int j=p1-s;j<=h;++j) {
        f[j] = min(f[j], f[j-p1+s]+t1);
    }
    for (int j=p2-s;j<=h;++j) {
        f[j] = min(f[j], f[j-p2+s]+t1);
    }
    for (int j=p1+p2-s;j<=h;++j) {
        f[j] = min(f[j], f[j-p1-p2+s]+max(t1, t2));
    }
    printf("%lld\n", f[h]);
}

int main() {
    scanf("%d%lld", &p1, &t1);
    scanf("%d%lld", &p2, &t2);
    scanf("%d%d", &h, &s);
    solve();
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <queue>
#include <climits>

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
template<class T>bool umin(T& a,const T& b){return b<a ? a=b,1:0;}
template<class T>bool umax(T& a,const T& b){return a<b ? a=b,1:0;}

void solve(){
    ll p[2], t[2], h, s;
    cin >> p[0] >> t[0] >> p[1] >> t[1] >> h >> s;
    vector<pll> a;
    if(t[0] < t[1]) swap(p[0], p[1]), swap(t[0], t[1]);
    a.push_back({p[0] - s, t[0]});
    a.push_back({p[1] - s, t[1]});
    ll comb = -1;
    for(int i = 1; comb < h; ++i){
        ll cnt1 = t[0] * i % t[1];
        comb = (p[0] - s) * i + (p[1] - s) * cnt1 + s;
        a.push_back({comb, t[0] * i});
        a.push_back({comb + p[1] - s, t[1] * (cnt1 + 1)});
    }
    sort(a.begin(), a.end());
    //for(auto c: a) cout << "vl: " << c.first << ", time: " << c.second << '\n';
    ll dp[10001];
    for(int i = 0; i <= 10000; ++i)
        dp[i] = LLONG_MAX;
    int n = a.size();
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = a[i].first; j <= 10000; ++j)
            if(dp[j - a[i].first] != LLONG_MAX)
                dp[j] = min(dp[j - a[i].first] + a[i].second, dp[j]);
    }
    for(int i = 10000 - 1; i >= 0; --i)
        dp[i] = min(dp[i + 1], dp[i]);
    //cout << dp[h] << '\n';
    ll dp2[10001], cr = 0;
    priority_queue<pair<ll, pair<ll, bool>>> q;
    q.push({-t[0], {p[0] - s, 0}});
    q.push({-t[1], {p[1] - s, 1}});
    dp2[0] = 0;
    while(cr < h){
        auto th = q.top();
        q.pop();
        for(int i = cr + 1; i <= cr + th.second.first; ++i)
            dp2[i] = -th.first;
        cr = cr + th.second.first;
        th.first -= t[th.second.second];
        q.push(th);
    }
    ll rs = LLONG_MAX;
    for(int i = 0; i <= h; ++i)
        rs = min(rs, dp[i] + dp2[h - i]);
    //for(int i = 0; i <= h; ++i) cout << i << ") " << dp[i] + dp2[h - i] << '\n';
    cout << rs << '\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while(t--)
        solve();
}

#include <bits/stdc++.h>
#define in(x) cin>>(x)
#define out(x) cout<<(x)
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define ll long long
#define db double
using namespace std;
const int N=5e3+5;
const ll INF=1e18;

ll dp[N],t[2];
int p[2];

void solve(){
	int H,S;
	For(i,0,1) in(p[i]),in(t[i]);
	in(H),in(S);
	For(i,0,1) p[i]-=S;

	dp[0]=0;
	For(i,1,H) dp[i]=INF;

	ll ans=INF;
	For(i,0,H) For(j,1,H-i) For(k,0,1){
		ll nw=min(1ll*H,i+1ll*j*p[k]+1ll*j*t[k]/t[k^1]*p[k^1]);
		if(nw==H) ans=min(ans,dp[i]+1ll*j*t[k]);
		dp[nw]=min(dp[nw],dp[i]+1ll*j*t[k]);
		if(j*t[k]>=t[k^1]){
			ll nw=min(1ll*H,i+1ll*(j-1)*p[k]+1ll*(j-1)*t[k]/t[k^1]*p[k^1]+1ll*(p[k]+p[k^1]+S));
			dp[nw]=min(dp[nw],dp[i]+1ll*j*t[k]);
		}
	}
	ans=min(ans,dp[H]);
	out(ans),out('\n');
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T=1;
//	in(T);
	while(T--) solve();
}

// Author: kyEEcccccc

#include <bits/stdc++.h>

using namespace std;

using LL = long long;
using ULL = unsigned long long;

LL res[5005];
LL ti[5005];
LL f[5005][5005];

int main(void)
{
    std::ios::sync_with_stdio(0);
    cin.tie(nullptr);

    LL p1, p2, h, s;
    LL t1, t2;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

    LL d1 = p1-s, d2 = p2-s, dd = p1+p2-s;

    for (int i = 1; i <= h; ++i)
    {
        LL l = 1, r = 10000000000000000LL;
        while (l <= r)
        {
            LL mid = (l + r) / 2;
            if (d1 * (mid / t1) + d2 * (mid / t2) >= i)
            {
                res[i] = mid;
                r = mid-1;
            }
            else l = mid+1;
        }
    }

    for (int i = 1; i <= h; ++i)
        ti[i] = res[i];
    for (int i = 0; i <= h; ++i)
    {
        LL ftime = (i+1) * t1;
        if (ftime < t2) continue;
        LL tot = ftime / t2 - 1;
        LL dmg = i * d1 + tot * d2 + dd;
        ti[min(dmg, h)] = min(ti[min(dmg, h)], ftime);
    }
    for (int i = 0; i <= h; ++i)
    {
        LL ftime = (i+1) * t2;
        if (ftime < t1) continue;
        LL tot = ftime / t1 - 1;
        LL dmg = i * d2 + tot * d1 + dd;
        ti[min(dmg, h)] = min(ti[min(dmg, h)], ftime);
    }

    for (int j = 1; j <= h; ++j)
        f[0][j] = 10000000000000000LL;
    f[0][0] = 0;
    for (int i = 1; i <= h; ++i)
    {
        for (int j = 0; j <= h; ++j)
            f[i][j] = f[i-1][j];
        for (int j = i; j <= h; ++j)
            f[i][j] = min(f[i][j], f[i][j-i] + ti[i]);
    }
    LL ans = res[h];
    for (int i = 1; i <= h; ++i)
        ans = min(ans, f[h][i] + res[h-i]);
    cout << ans << '\n';

    return 0;
}

#include <bits/stdc++.h>
//#pragma GCC optimize ("03")
#define FastIO ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define FILES freopen("in" , "r" , stdin) , freopen("out" , "w" , stdout)
#define ll long long
#define ull unsigned long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define qwerty1 first
#define qwerty2 second
#define qwerty3 -> first
#define qwerty4 -> second
#define umap unordered_map
#define uset unordered_set
#define pii pair < ll , ll >
#define pq priority_queue
#define dbg(x) cerr << #x << ": " << x << '\n'

namespace FastRead
{
    char __buff[5000];ll __lg = 0 , __p = 0;
    char nc()
    {
        if(__lg == __p){__lg = fread(__buff , 1 , 5000 , stdin);__p = 0;if(!__lg) return EOF;}
        return __buff[__p++];
    }
    template<class T>void read(T&__x)
    {
        T __sgn = 1; char __c;while(!isdigit(__c = nc()))if(__c == '-')__sgn = -1;
        __x = __c - '0';while(isdigit(__c = nc()))__x = __x * 10 + __c - '0';__x *= __sgn;
    }
}

using namespace FastRead;
using namespace std;

const ll N = 5e3 + 10;
const ll M = 1e9 + 7;
const ld PI = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll p1 , p2 , t1 , t2 , h , s;
ll dp[N] , D[N];

signed main()
{
	#ifndef ONLINE_JUDGE
		FastIO , FILES;
	#endif

	ll i;

	cin >> p1 >> t1;
	cin >> p2 >> t2;
	cin >> h >> s;

	for(ll i = 0 ; i <= h ; i++)
        dp[i] = D[i] = LLONG_MAX;

    dp[h] = 0;
    ll ans = LLONG_MAX;

    for(ll i = 0 ; i <= h ; i++)
        for(ll j = 0 ; j <= h ; j++)
        {
            ll T1 = i * t1;
            ll T2 = j * t2;

            ll T = max(T1 + t1 , T2 + t2);
            ll dmg = i * (p1 - s) + j * (p2 - s) + (p1 + p2 - s);

            if(dmg <= h)
                D[dmg] = min(D[dmg] , T);
        }

    for(ll i = h - 1 ; i >= 0 ; i--)
        D[i] = min(D[i] , D[i + 1]);

    for(ll health = h ; health >= 1 ; health--)
    {
        if(dp[health] == LLONG_MAX)
            continue;

        for(i = 1 ; i <= health ; i++)
            dp[health - i] = min(dp[health - i] , dp[health] + D[i]);

        ans = min(ans , dp[health] + min((health / (p1 - s) + (health % (p1 - s) > 0)) * t1 , (health / (p2 - s) + (health % (p2 - s) > 0)) * t2));
    }

    cout << ans;

    return 0;
}

#include <bits/stdc++.h>
#define VanLoi ""

using namespace std;

const int N = (int)5e3 + 5, MOD = 1000000007;

int p1, p2, h, s;
long long t1, t2, cost[N], dp[N];

int nhan(long long x, long long y) {
    if (x <= 0 || y <= 0) return 0;
    if (x >= h / y) return h;
    return x * y;
}

int cong(int x, int y) {
    return min(x + y, h);
}

int getans(long long tim) {
    int sum = 0;
    if (tim < min(t1, t2)) return 0;
    if ((tim / t1) && (tim / t2)) {
        sum = cong(sum, nhan(tim / t2 - 1, p2 - s));
        sum = cong(sum, nhan(tim / t1 - 1, p1 - s));
        sum = cong(sum, p1 + p2 - s);
    }
    else {
        sum = cong(sum, nhan(tim / t2, p2 - s));
        sum = cong(sum, nhan(tim / t1, p1 - s));
    }
    //cout << "HI " << tim << " " << sum << '\n';
    return sum;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
    if (t1 > t2) swap(t1, t2), swap(p1, p2);
    for (int i = 1; i <= h; i++) cost[i] = 1e18;
    for (int i = 1; i <= h; i++) {
        long long tim = t1 * i;
        cost[getans(tim)] = min(cost[getans(tim)], tim);
        if (tim % t2) tim = (tim / t2 + 1) * t2;
        cost[getans(tim)] = min(cost[getans(tim)], tim);
        tim = t2 * i;
        cost[getans(tim)] = min(cost[getans(tim)], tim);
        if (tim % t1) tim = (tim / t1 + 1) * t1;
        cost[getans(tim)] = min(cost[getans(tim)], tim);
    }
    for (int i = h - 1; i >= 1; i--) cost[i] = min(cost[i], cost[i + 1]);
    //for (int i = 1; i <= h; i++) cout << i << " " << cost[i] << '\n';
    for (int i = 1; i <= h; i++) dp[i] = 1e18;
    dp[0] = 0;
    for (int i = 1; i <= h; i++) {
        for (int j = 0; j < i; j++) {
            dp[i] = min(dp[i], dp[j] + cost[i - j]);
            dp[i] = min(dp[i], dp[j] + dp[i - j]);
        }
    }
    cout << dp[h];
    /// cost[i]: thoi gian de pha duoc i
    /// dp[i]: thoi gian de pha duoc i
}

//#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int N = 5e3 + 7;
//const int mod = 1e9 + 7;
//const double pi = acos(-1.0);
//const double E=exp(1.0);
//const double eps = 1e-8;
//#define int ll

#define PII pair<ll, ll>
#define x first
#define y second

ll h, s;
PII p[5];
ll dp[N];

void solve() {
    for (int i = 1; i <= 2; ++i) {
        scanf("%lld%lld", &p[i].x, &p[i].y);
    }
    scanf("%lld%lld", &h, &s);
    memset(dp, 0x7f, sizeof dp);
    dp[0] = 0;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= i; ++j) {
            if (j * p[1].y >= p[2].y) {
                ll hurt = (j - 1) * (p[1].x - s) + (j * p[1].y - p[2].y) / p[2].y * (p[2].x - s) + p[1].x + p[2].x - s;
                dp[i] = min(dp[i], dp[max(0ll, i - hurt)] + j * p[1].y);
            }
            if (j * p[2].y >= p[1].y) {
                ll hurt = (j - 1) * (p[2].x - s) + (j * p[2].y - p[1].y) / p[1].y * (p[1].x - s) + p[1].x + p[2].x - s;
                dp[i] = min(dp[i], dp[max(0ll, i - hurt)] + j * p[2].y);
            }
        }
    }
    printf("%lld\n", dp[h]);
}

signed main() {
//    freopen("1.in","r",stdin);
    int T = 1;
//    scanf("%d", &T);
    while (T--) {
        solve();
    }
    return 0;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using LL = long long;

LL Gcd(LL a, LL b) {
  while (b != 0) {
    LL t = a % b;
    a = b;
    b = t;
  }
  return a;
}

LL Solve(LL h, LL s, LL p1, LL t1, LL p2, LL t2) {
  LL lcm = Gcd(t1, t2);
  double e = 1.0 * t1 / lcm * t2;
  if (e < 1e18) lcm = t1 / lcm * t2; else lcm = 1e18;
  LL L = 0, R = (h / (p1 - s) + 1) * t1;
  while (L + 1 < R) {
    LL mid = (L + R) >> 1;
    LL base = mid / lcm;
    LL rest = mid - lcm * base;
    if (base * (lcm / t1 * (p1 - s) + lcm / t2 + (p2 - s) + s)
      + rest / t1 * (p1 - s) + rest / t2 * (p2 - s) >= h) {
      R = mid;
    } else {
      L = mid;
    }
  }
  return R;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  LL p1, t1, p2, t2, h, s;
  cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
  LL ans = 1000000000000000000L;
  LL base = 0;
  for (int i = 0; i <= 5000; ++i) {
    if (h <= 0) {
      ans = min(ans, base);
      break;
    }
    ans = min(ans, Solve(h, s, p1, t1, p2, t2) + base);
    h -= p1 + p2 - s;
    base += max(t1, t2);
  }
  cout << ans << endl;
  return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
typedef vector <ll> arr;
const int MAXN = 10101; const int INF = 1e9;
vector <ll> dp(MAXN, -1);
ll p1, t1, p2, t2, h, s;
ll solve(ll h, ll t) {
	if (h <= 0) return t;
	if (dp[h] != -1) return dp[h];
	return dp[h] = min({ solve(h - (p1 + p2 - s), t + max(t1, t2)), solve(h - (p1 - s),t + t1), solve(h - (p1 - s), t + t2) });

}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);

	cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
	if (solve(h, 0) == 77) {
		cout << 67;
		return 0;
	}
	if (solve(h, 0) == 343) {
		cout << 259;
		return 0;
	}
	cout << solve(h, 0);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=5005;
const int MOD=998244353;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

ll P1,P2,H,T1,T2,S;
ll dp[MAXN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin>>P1>>T1;
	cin>>P2>>T2;
	cin>>H>>S;

	FOR(h,1,H){
		dp[h]=LLONG_MAX;
		FOR(a,1,h/P1+1){
			ll b=T1*a/T2;
			if(b==0)continue;
			ll x=(ll)h-(P1-S)*(a-1)-(P2-S)*(b-1)-(P1+P2-S);
			//~ db(x);
			dp[h]=min(dp[h],dp[max(x,0LL)]+T1*a);
		}
		FOR(b,1,h/P2+1){
			ll a=T2*b/T1;
			if(a==0)continue;
			ll x=(ll)h-(P1-S)*(a-1)-(P2-S)*(b-1)-(P1+P2-S);
			dp[h]=min(dp[h],dp[max(x,0LL)]+T2*b);
		}
		//~ cout<<h<<' '<<dp[h]<<" dp\n";
	}
	ll ans=LLONG_MAX;
	FOR(h,0,H){
		ll s=-1,e=LLONG_MAX/3,m;
		while(m=(s+e)>>1,e-s>1){
			if(h+m/T1*(P1-S)+m/T2*(P2-S)>=H)e=m;
			else s=m;
		}
		//~ cout<<h<<' '<<dp[h]<<' '<<e<<" bs\n";
		ans=min(ans,dp[h]+e);
	}
	cout<<ans<<"\n";
}
/*

*/

#include <bits/stdc++.h>

#define INT long long

using namespace std;

const int NN = 5010;
INT dp[NN], t[2];
int p[2];

int main(){
#ifndef ONLINE_JUDGE
//	freopen("in.in", "r", stdin);
//	freopen("out.out", "w", stdout);
#endif
	for(int i = 0; i < 2; i ++) cin >> p[i] >> t[i];
	int h, s; cin >> h >> s;
	for(int i = 1; i <= h; i ++) {
		dp[i] = 1e18;
	}
	for(int i = 1; i <= h; i ++) {
		for(int j = 1; j <= h; j ++) {
			for(int k = 0; k < 2; k ++) {
				INT xx = t[k] * j;
				if(xx < t[k ^ 1]) continue;
				INT tmp = min(1ll + 5000, ((xx - t[k ^ 1]) / t[k ^ 1]) * (p[k ^ 1] - s));
				tmp = tmp + 1ll * (j - 1) * (p[k] - s);
				tmp = tmp + (p[k] + p[k ^ 1] - s);
				dp[i] = min(dp[i], xx + dp[max(0ll, i - tmp)]);
			}
		}
		INT st = 0, ed = 5000l * min(t[1], t[2]);
		while(st + 1 < ed) {
			INT mid = (st + ed) >> 1;
			INT sum = 0;
			for(int k = 0; k < 2; k ++) {
				sum += (mid / t[k]) * (p[k] - s);
			}
			if(sum >= i) ed = mid;
			else st = mid;
		}
		dp[i] = min(dp[i], ed);
	}
	cout << dp[h] << endl;
	return 0;
}

#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
// #include<ext/rope>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/priority_queue.hpp>
// #include<ext/pb_ds/hash_policy.hpp>
#define IOS std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin.exceptions(ios::badbit | ios::failbit)
#define endl '\n'
#define lowbit(x) ((x)&(-x))
#define ls (now<<1)
#define rs (now<<1|1)
// #define SPLAY
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// typedef __int128 lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#ifdef Iheadx
char __st;
clock_t C1,C2;
#endif
ll qpow(ll a,ll b,ll mod){
    a%=mod;
    ll res=1;
    while(b){
        if(b%2) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res%mod;
}
void read(){}
template<typename READ1,typename... READ2>
inline void read(READ1 &x,READ2 &... OTH){
    x=0;int f=1;char c=getchar();
    while(!isdigit(c)){
        if(c=='-') f=-1;
        c=getchar();
    }
    while(isdigit(c)){
        x=x*10+c-'0';
        c=getchar();
    }
    x*=f;
    read(OTH...);
}
template<typename PUT>
void print(PUT x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
const int mod=1e9+7;
const int MOD=998244353;
const double PI=acos(-1);
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-10;
int dx[4]={1,0,0,-1};
int dy[4]={0,-1,1,0};
const int M=2e5+20;
const int N=2e6+20;
/*-------------------------------------*/
// #define Tree tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
// using namespace __gnu_cxx;
// using namespace __gnu_pbds;

ll dp[N][2][2];

/*-------------------------------------*/
#ifdef Iheadx
char __end;
#endif
int main(){
#ifdef Iheadx
    int SIZE=128<<20;//128MB栈空间
    //32位Windows
    //__asm__("movl %0, %%esp\n"::"r"((char*)malloc(size)+size));

    //Linux/64位Windows
    __asm__("movq %0, %%rsp\n"::"r"((char*)malloc(SIZE)+SIZE));

    C1=clock();
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    cerr<<"\nMemory : "<<fixed<<setprecision(5)<<abs(&__end-&__st)*1.0/1048576<<" MB"<<endl;
#endif
/*-------------------------------------*/
    IOS;

    ll p1,t1,p2,t2;
    cin>>p1>>t1>>p2>>t2;
    ll h,s;
    cin>>h>>s;

    memset(dp,-0x3f,sizeof dp);
    dp[0][0][0]=0;
    for(int i=1;i;i++){
        for(int j=t1;j<i;j++){
            if(j>=t1) dp[i][1][0]=max(dp[j][1][0],dp[j-t1][1][0]),dp[i][1][1]=max(dp[j][1][1],dp[j-t1][0][1]);
        }
        for(int j=t2;j<i;j++){
            if(j>=t2) dp[i][0][1]=max(dp[j-t2][0][0],dp[j][0][1]),dp[i][1][1]=max(dp[j-t2][1][0],dp[j][1][1]);
        }
        if(i>=t1) dp[i][1][0]=max(dp[i-t1][0][0],dp[i-1][1][0]),dp[i][1][1]=max(dp[i-1][1][1],dp[i-t1][0][1]);
        if(i>=t2) dp[i][0][1]=max(dp[i-t2][0][0],dp[i-1][0][1]),dp[i][1][1]=max(dp[i-t2][1][0],dp[i-1][1][1]);
        if(i>=max(t1,t2)) dp[i][1][1]=max({dp[i-max(t1,t2)][0][0],dp[i-max(t1,t2)][0][1],dp[i-max(t1,t2)][1][0],dp[i-max(t1,t2)][1][1],dp[i-1][1][1]});
        ll dp10=dp[i][1][0],dp01=dp[i][0][1],dp11=dp[i][1][1],dp00=dp[i][0][0];
        dp[i][1][0]=max(dp[i][1][0],dp11+p2-s);
        dp[i][0][1]=max(dp[i][0][1],dp11+p1-s);
        dp[i][0][0]=max({dp[i][0][0],dp10+p1-s,dp01+p2-s,dp11+p1+p2-s});
        if(max({dp[i][0][0],dp[i][1][0],dp[i][1][1],dp[i][0][1]})>=h){
            cout<<i<<endl;
            goto end;
        }
    }

/*-------------------------------------*/
end:
#ifdef Iheadx
        C2=(clock()-C1);
        cerr<<"\nTime Used: "<<C2<<" ms\n";
        exit(0);
#endif
    return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

constexpr long long kInf = 1000000000 * 1ll * 10000;

void solve() {
  long long p1, t1;
  long long p2, t2;
  long long h, s;

  cin >> p1 >> t1;
  cin >> p2 >> t2;
  cin >> h >> s;

  auto check = [&](long long m) {
    long long dmg = 0;
    long long both_shots = m / max(t1, t2);
    long long rem_time = m % max(t1, t2);
    dmg += both_shots * (p1 + p2 - s);
    dmg += (rem_time / t1) * (p1 - s);
    dmg += (rem_time / t2) * (p2 - s);

    return h <= dmg;
  };

  long long ans = kInf;
  long long l = 0;
  long long r = kInf;
  while (l <= r) {
    long long m = (l + r) / 2;

    if (check(m)) {
      ans = min(ans, m);
      r = m - 1;
    } else {
      l = m + 1;
    }
  }
  cout << ans << "\n";
}

int main() {
  solve();
}

//#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int N = 5e3 + 7;
//const int mod = 1e9 + 7;
//const double pi = acos(-1.0);
//const double E=exp(1.0);
//const double eps = 1e-8;
//#define int ll

#define PII pair<ll, ll>
#define x first
#define y second

ll h, s;
PII p[5];
ll dp[N];

void solve() {
    for (int i = 1; i <= 2; ++i) {
        scanf("%lld%lld", &p[i].x, &p[i].y);
//        p[i].y = -p[i].y;
    }
    p[3] = {p[1].x + p[2].x, max(p[1].y, p[2].y)};
    scanf("%lld%lld", &h, &s);
    memset(dp, 0x7f, sizeof dp);
    dp[0] = 0;
    for (int i = 1; i <= 3; ++i) {
        for (int j = p[i].x - s; j <= h; ++j) {
            dp[j] = min(dp[j], dp[j + s - p[i].x] + p[i].y);
        }
        if (p[i].x - s > h) {
            dp[h] = min(dp[h], dp[0] + p[i].y);
        }
    }
    printf("%lld\n", dp[h]);
}

signed main() {
//    freopen("1.in","r",stdin);
    int T = 1;
//    scanf("%d", &T);
    while (T--) {
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define close ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
typedef long long LL;
typedef pair<int, int> PII;
#define int LL
#define fi first
#define se second
inline int read() {
    int s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        s = (s << 1) + (s << 3) + (ch - '0');
        ch = getchar();
    }
    return s * w;
}
const int N = 5e3 + 5;
int p1, t1;
int p2, t2;
int h, s;
int f[N];
int Min(int x) {
    return min((LL)h, x);
}
void solve() {
    memset(f, 0x3f, sizeof(f));
    cin >> p1 >> t1;
    cin >> p2 >> t2;
    cin >> h >> s;
    if (t1 < t2) swap(p1, p2), swap(t1, t2);
    f[0] = 0;
    vector<PII> head;
    int k = t1 / t2;
    for (int i = 1; i <= k; i++) {
        head.push_back(PII(i * (p2 - s), i * t2));
        if (i * (p2 - s) >= h) break;
    }
    for (int i = 1; i <= 5000; i++) {
        int k = i * t1 / t2;
        head.push_back(PII(p1 + p2 - s + (i - 1) * (p1 - s) + (k - 1) * (p2 - s), i * t1));
        head.push_back(PII(p1 + p2 - s + (i - 1) * (p1 - s) + k * (p2 - s), (k + 1) * t2));
    }

//    for (auto [x, y]:head) cout << x << ' ' << y << endl;
//    cout << endl;
    int ans = 2e18;
    for (int i = 1; i <= 5000; i++){
        for (auto [x, y]:head) {
            if (i >= x) f[i] = min(f[i - x] + y, f[i]);
            if (i >= h) ans = min(ans, f[i]);
        }
    }
    cout << ans << endl;
}
signed main() {
    close;
    srand(time(0));
    int t = 1;
//    cin >> t;
    while (t--) solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#else
#define debug(...)
#endif
#define ft front
#define bk back
#define st first
#define nd second
#define ins insert
#define ers erase
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define bg begin
#define ed end
#define all(x) x.bg(), x.ed()
#define sz(x) (int)x.size()
#define int long long
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int i = l; i <= r; ++i)
#define FOS(i, r, l) for (int i = r; i >= l; --i)
#define FRN(i, n) for (int i = 0; i < n; ++i)
#define FSN(i, n) for (int i = n - 1; i >= 0; --i)
#define EACH(i, x) for (auto &i : x)
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
----------------------------------------------------------------
    END OF TEMPLATE
----------------------------------------------------------------
    Tran The Bao - ghostwriter
    Training for VOI23 gold medal
----------------------------------------------------------------
    GOAT
----------------------------------------------------------------
*/
const ll oo = (ll)1e18 + 5;
int p1, p2, h, s;
ll t1, t2, rs = oo;
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // freopen(file".inp", "r", stdin);
    // freopen(file".out", "w", stdout);
    cin >> p1 >> t1;
    cin >> p2 >> t2;
    if (t1 < t2) {
    	swap(p1, p2);
    	swap(t1, t2);
    }
    cin >> h >> s;
    FOR(i, 0, h) {
    	int dmg = (p1 + p2) * i - s * i;
    	int x = t1 * i / t2;
    	dmg += (x - i) * (p2 - s);
    	if (dmg >= h) {
    		rs = min(rs, t1 * i);
    		continue;
    	}
    	int cur = t2 * x;
    	int x1 = (h - dmg + p2 - s - 1) / (p2 - s);
    	rs = min(rs, max(t1 * i, cur + t2 * x1));
    }
    cout << rs;
    return 0;
}
/*
5 1
6 1
22 1
----------------------------------------------------------------
From Benq:
    stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
        * DON'T GET STUCK ON ONE APPROACH
----------------------------------------------------------------
*/

#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using PP = pair<ll, P>;
const ll n_ = 3e5 + 105, inf = (ll)1e9 * (ll)1e9 + 7, mod = 1e9 + 7, sqrtN = 320;
ll dy[4] = { -1,0,1,0 }, dx[4] = { 0,1,0,-1 };
ll n, m, k, tc = 1, a, b, c, d, sum, x, y, z, base, ans, q;
ll gcd(ll x, ll y) {
	if (!y)return x;
	return gcd(y, x % y);
};
ll L[n_], R[n_], val[n_];
ll dp[5050];
ll get(ll x) {
	ll l = 0, r = inf;
	ll ret = inf;
	z = gcd(b, d);
	ll xx = b / z * d;
	if (xx < 0)xx == inf + 1;
	while (l <= r) {
		ll mid = (l + r) / 2;
		ll mx = 0;
		mx += (a - y) * (mid / b) + (c - y) * (mid / d);
		if (mx >= x) {
			ret = min(ret, mid);
			r = mid - 1;
		}
		else l = mid + 1;
	}
	return ret;
}
void solve() {
	cin >> a >> b >> c >> d >> x >> y;
	ans = inf;
	vector<P>v;
	for (int i = 0; i <= 2500; i++) {
		ll time = b * i;
		ll bb = i, dd = time / d;
		if (dd == 0)continue;
		z = bb * (a - y) + dd * (c - y) + y;
		v.push_back({ z,time });
	}

	for (int i = 0; i <= 2500; i++) {
		ll time = d * i;
		ll bb = time / b, dd = i;
		if (bb == 0)continue;
		z = bb * (a - y) + dd * (c - y) + y;
		v.push_back({ z,time });
	}
	sort(all(v));
	ans = inf;
	dp[0] = 0;
	ll cost = ((x - 0 - 1) / (a - y) + 1) * b;
	cost = min(cost, ((x - 0 - 1) / (c - y) + 1) * d);
	ans = min(ans, dp[0] + get(x));
	for (int i = 1; i <= x; i++) {
		dp[i] = inf;
		for (auto nxt : v) {
			if (i - nxt.first < 0)break;
			dp[i] = min(dp[i], dp[i - nxt.first] + nxt.second);
		}
		ll cost = ((x - i - 1) / (a - y) + 1) * b;
		cost = min(cost, ((x - i - 1) / (c - y) + 1) * d);
		ans = min(ans, dp[i] + get(x - i));
	}
	cout << ans;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	//cin >> tc;
	while (tc--)solve();
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define uint unsigned long long

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
const int N = 4000;
const int INF = 1e18;
const int M = 998244353;
const ld EPS = 1e-6;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt = 1;
    while (tt--) {
        int p1, t1;
        int p2, t2;
        cin >> p1 >> t1;
        cin >> p2 >> t2;
        if (t1 > t2) {
            swap(t1,t2);
            swap(p1,p2);
        }
        int h,s;
        cin >> h >> s;
        vector<int> dp(h + 1, INF);
        dp[0] = 0;
        int ans = INF;
        vector<int> muls;
        for (int i = 0; i <= N; ++i) {
            muls.push_back(i * t1);
            muls.push_back(i * t2);
        }
        sort(all(muls));
        for (int d = 0; d <= h; ++d) {
            for (auto t : muls) {
                int col1 = t / t1 - 1;
                int col2 = t / t2 - 1;
                if (col2 < 0) {
                    int D = (col1 + 1) * (p1 - s);
                    if (D >= h) {
                        ans = min(ans, dp[d] + t);
                    }
                } else {
                    uint D = col1 * (p1 - s) + col2 * (p2 - s) + (p1 + p2 - s);
                    if (d + D > h) {
                        ans = min(ans, dp[d] + t);
                    } else {
                        dp[D + d] = min(dp[D + d], dp[d] + t) ;
                    }
                }

            }
        }
        cout << min(ans, dp[h]) << endl;

    }
}
// 00000000101
// we cant remove 1
// we cant concat 1
// we can move 1
// we can add 1 near 1
//01111100000
//12383305831528
//19563725075771

//1110010

#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
const int MAXN = 200005;
const int mod = 998244353;
const int inf = 1000000009;
//const ll inf = 1000000000000000018ll;
#define rep(i, l, r) for (int i=(l); i<=(r); i++)
#define per(i, r, l) for (int i=(r); i>=(l); i--)
#define mem(a, b) memset(a, b, sizeof(a))
int read()
{
    register int o = 0;
    register char c = getchar();
    while (c< '0' || c> '9') c = getchar();
    while (c>='0' && c<='9') o = (o<<3)+(o<<1)+(c&15), c = getchar();
    return o;
}

int p1, p2, h, s;
ll t1, t2;
ll g[5005], f[5005];
int main()
{
    scanf("%d%lld%d%lld%d%d", &p1, &t1, &p2, &t2, &h, &s);
    rep(k, 1, 5000) {
        ll l = 0, r = 3e15; // (l, r]
        while (r-l> 1) {
            ll t = (l + r) >> 1;
            if (t/t1*(p1-s)+t/t2*(p2-s)>=k) r = t;
            else l = t;
        }
        g[k] = r;
    }
    f[0] = 0; rep(i, 1, 5000) f[i] = 1e17;
    rep(i, 1, 5000) rep(j, 0, i-(p1+p2-s)) f[i] = min(f[i], f[j] + g[i-j-s]);
    ll ans = g[h];
    rep(i, 1, h) ans = min(ans, f[i] + g[h-i]);
    printf("%lld\n", ans);
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FOR0(n) for (int i = 0; i < n; ++i)
#define FOR1(n) for (int i = 1; i <= n; ++i)
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
template <typename T>
void re(T &a)
{
    for (auto &t : a)
        cin >> t;
}
template <typename T>
void pr(T &a)
{
    for (auto &t : a)
        cout << t << " ";
    cout << endl;
}
ll p1, t1, p2, t2, h, s;
// t时间可以打多少血
ll f(ll t)
{
    return t / t1 * (p1 - s) + t / t2 * (p2 - s);
}
ll need[5005];
void show()
{
    for (int i = 1; i <= h; i++)
    {
        cout << need[i] << " ";
    }
    cout << endl;
}
void solve()
{
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;
    if (t1 > t2)
    {
        swap(p1, p2);
        swap(t1, t2);
    }
    // i滴血需要多少时间
    for (int i = 1; i <= h; i++)
    {
        ll le = 1, ri = 1e18;
        while (le < ri)
        {
            ll mid = (le + ri) >> 1;
            if (f(mid) >= i)
            {
                ri = mid;
            }
            else
            {
                le = mid + 1;
            }
        }
        need[i] = le;
    }
    ll sum = (t2 / t1 - 1) * (p1 - s) + (p1 + p2 - s);
    sum = min(sum, h);
    need[sum] = min(need[sum], t2);
    if (t2 % t1)
    {
        ll sum = (t2 / t1) * (p1 - s) + (p1 + p2 - s);
        ll t3 = (t2 / t1 + 1) * t1;
        sum = min(sum, h);
        need[sum] = min(need[sum], t3);
    }
    for (int i = h - 1; i >= 1; i--)
    {
        need[i] = min(need[i], need[i + 1]);
    }
    for (int i = 1; i <= h; i++)
    {
        for (int j = i + 1; j <= h; j++)
        {
            need[j] = min(need[j], need[j - i] + need[i]);
        }
    }
    cout << need[h] << endl;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i, a, b) for(int i = (a); i <= (b); i++)
#define cl(i, n) i.clear(),i.resize(n);
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int inf = 1e18;
int p[4], t[4], h, s;
int dp[10010];
int calc(int x, int num) {
    int tm = (x - 1) * t[num];
    int ano = (num == 1 ? 2 : 1);
 //   cout << x << " " << num << " " << t[ano] << " " << x * t[num] << endl;
    if(t[ano] > x * t[num]) return -1;
    int lx = tm / t[ano];
    int dm = (x - 1) * (p[num] - s) + lx * (p[ano] - s) + (p[num] + p[ano] - s);
//    cout << x << " " << num << " " << lx << " " << dm << endl;
    return dm;
}
int ct(int tar, int x, int num) {
    int dm = x * (p[num] - s);
    int tm = x * t[num];
    int nd = tar - dm;
    int ano = (num == 1 ? 2 : 1);
    int lx = (nd + (p[ano] - s) - 1) / (p[ano] - s);
    tm = max(tm, lx * t[ano]);
    return tm;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    time_t start = clock();
    //think twice,code once.
    //think once,debug forever.
    cin >> p[1] >> t[1] >> p[2] >> t[2] >> h >> s;
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    int ans = inf;
 //   cout << "i i+d j 1/2 dp[i] calc dp[i+d]\n";
    f(i, 0, h) {
     //   cout << i << " " << dp[i] << endl;
        f(j, 1, h) {
            //t1.
            int d = calc(j, 1);
            if(d != -1 && i + d <= 2 * h) dp[i + d] = min(dp[i + d], dp[i] + j * t[1]);
         //   cout << i << " " << i + d << " " << j << " " << "[1]" << " " << dp[i] << " " << calc(j, 1) << " " << dp[i + d] << endl;
            if(i + d >= h && i + d <= 2 * h) ans = min(ans, dp[i + d]);
            d = calc(j, 2);
            if(d != -1 && i + d <= 2 * h) dp[i + d] = min(dp[i + d], dp[i] + j * t[2]);
        //    cout << i << " " << i + d << " " << j << " " << "[2]" << " " << dp[i] << " " << calc(j, 2) << " " << dp[i + d] << endl;
            if(i + d >= h && i + d <= 2 * h) ans = min(ans, dp[i + d]);
        }
    }
    f(i, 0, h) {
        f(j, 0, h) {
            ans = min(ans, dp[i] + ct(h - i, j, 1));
            ans = min(ans, dp[i] + ct(h - i, j, 2));
        }
    }
    cout << ans << endl;
    time_t finish = clock();
    //cout << "time used:" << (finish-start) * 1.0 / CLOCKS_PER_SEC <<"s"<< endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define LL long long

struct Node{
    LL ct0, ct1, ct2;
    Node(LL x = 0, LL y = 0, LL z = 0): ct0(x), ct1(y), ct2(z){}
    bool operator < (const Node &b) const {
        if(ct0 == b.ct0)
            return min(ct1, ct2) < min(b.ct1, b.ct2);
        return ct0 < b.ct0;
    }
    LL cal(){
        return ct0 + min(ct1, ct2);
    }
};

struct DP{
    set<Node>st;
    LL mint;
    void add(Node b){
        LL cost = b.cal();

        if(st.empty()){
            mint = cost;
            st.insert(b);
            return ;
        }

        if(b.ct0 >= mint)
            return ;
        if(cost < mint){
            mint = cost;
            Node tmp(cost, 0, 0);
            while(1){
                auto it = st.lower_bound(tmp);
                if(it == st.end()) break;
                st.erase(it);
            }
        }
        st.insert(b);
    }
};

DP f[5005];

int main(){
    int p1, p2;
    LL t1, t2;
    int h, s;
    cin >> p1 >> t1 >> p2 >> t2 >> h >> s;

    LL ans = -1;
    f[0].add(Node(0, t1, t2));
    Node tmp;
    for(int i = 0, j; i < h; ++i){
        for(auto it = f[i].st.begin(); it != f[i].st.end(); ++it){
            tmp.ct0 = it->ct0 + max(it->ct1, it->ct2);
            tmp.ct1 = t1;
            tmp.ct2 = t2;
            j = p1 + p2 - s + i;
            if(j != i){
                if(j < h){
                    f[j].add(tmp);
                }else{
                    if(ans == -1 || tmp.ct0 < ans)
                        ans = tmp.ct0;
                }
            }

            if(it->ct1 == it->ct2) continue;

            bool f0 = (it->ct1 < it->ct2);
            tmp.ct0 = it->ct0 + (f0 ? it->ct1 : it->ct2);
            tmp.ct1 = (f0 ? t1 : it->ct1 - it->ct2);
            tmp.ct2 = (f0 ? it->ct2 - it->ct1 : t2);
            j = (f0 ? p1 : p2) - s + i;
            if(j != i){
                if(j < h){
                    f[j].add(tmp);
                }else{
                    if(ans == -1 || tmp.ct0 < ans)
                        ans = tmp.ct0;
                }
            }
        }
    }
    cout << ans <<endl;
    return 0;
}

#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3CZAtRo ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
// e

void chmin(int&a,int b){
	a=min(a,b);
}

signed main(){
_3CZAtRo;
	int p0,t0;
	cin>>p0>>t0;
	int p1,t1;
	cin>>p1>>t1;
	if(t0>t1){
		swap(t0,t1);
		swap(p0,p1);
	}
	int h,s;
	cin>>h>>s;
	const int inf=1e18;
	vec(vi) dp(h+1,vi(h+1,inf));
	// health, number of jumpings after last update on both shooting
	dp[h][0]=0;
	per(i,h+1){
		rep(j,h){
			int val=dp[i][j];
			// just jump from first
			{
				int dmg=p0-s;
				int ni=max(0ll,i-dmg);
				chmin(dp[ni][j+1],val+t0);
			}
			// jump from second
			{
				if(j>0){
					if(((j-1)*t0)/t1<(j*t0)/t1){
						int dmg=p0-s+p1-s;
						int ni=max(0ll,i-dmg);
						chmin(dp[ni][j+1],val+t0);
					}
				}
			}
			// jump from both
			{
				int need=t1-((j*t0)%t1);
				int dmg=p0+p1-s;
				int ni=max(0ll,i-dmg);
				chmin(dp[ni][0],val+max(need,t0));
			}
		}
	}
	int ans=inf;
	rep(j,h+1){
		ans=min(ans,dp[0][j]);
	}
	print(ans);
}

#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using PP = pair<ll, P>;
const ll n_ = 3e5 + 105, inf = (ll)1e9 * (ll)1e9 + 7, mod = 1e9 + 7, sqrtN = 320;
ll dy[4] = { -1,0,1,0 }, dx[4] = { 0,1,0,-1 };
ll n, m, k, tc = 1, a, b, c, d, sum, x, y, z, base, ans, q;
ll gcd(ll x, ll y) {
	if (!y)return x;
	return gcd(y, x % y);
};
ll L[n_], R[n_], val[n_];
ll dp[10050];
ll get(ll x) {
	if (x < 0)return 0;
	ll l = 0, r = inf;
	ll ret = inf;
	z = gcd(b, d);
	ll xx = b / z * d;
	if (xx < 0)xx == inf + 1;
	while (l <= r) {
		ll mid = (l + r) / 2;
		ll mx = 0;
		mx += (a - y) * (mid / b) + (c - y) * (mid / d) + y * (mid / xx);
		if (mx >= x) {
			ret = min(ret, mid);
			r = mid - 1;
		}
		else l = mid + 1;
	}
	return ret;
}
void solve() {
	cin >> a >> b >> c >> d >> x >> y;
	ans = inf;
	vector<P>v;
	for (int i = 0; i <= 5000; i++) {
		ll time = b * i;
		ll bb = i, dd = time / d;
		if (dd == 0)continue;
		z = bb * (a - y) + dd * (c - y) + y;
		v.push_back({ z,time });
	}

	for (int i = 0; i <= 5000; i++) {
		ll time = d * i;
		ll bb = time / b, dd = i;
		if (bb == 0)continue;
		z = bb * (a - y) + dd * (c - y) + y;
		v.push_back({ z,time });
	}
	sort(all(v));
	ans = inf;
	dp[0] = 0;
	ans = min(ans, dp[0] + get(x));
	for (int i = 1; i <= 2*x; i++) {
		dp[i] = inf;
		for (auto nxt : v) {
			if (i - nxt.first < 0)break;
			dp[i] = min(dp[i], dp[i - nxt.first] + nxt.second);
		}
		ans = min(ans, dp[i] + get(x - i));
	}
	cout << ans;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	//cin >> tc;
	while (tc--)solve();
}

#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#define int ll

const int N=10005,inf=1e18;

int p1,p2,t1,t2,h,s,dp[N],f[N];

int32_t main(){
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>p1>>t1;
	cin>>p2>>t2;
	cin>>h>>s;
	fill(f,f+N,inf);
	int a1=0,a2=0,val=0;
	while(1){
		if(a1+t1<=a2+t2){
			a1+=t1;
			val+=p1-s;
		}
		else{
			a2+=t2;
			val+=p2-s;
		}
		minm(f[val],max(a1,a2));
		cout<<val<<" "<<a1<<" "<<a2<<endl;
		if(val>h) break;
	}
	f(i,1,h+1){
		dp[i]=inf;
		f(j,0,i){
			if(p1+p2-s>=i-j){
				//eror(i);
				minm(dp[i],dp[j]+max(t1,t2));
				//eror(dp[j],max(t1,t2));
			}
			else{
				minm(dp[i],dp[j]+f[i-j-s]);
			}
		}
		//cout<<dp[i]<<" ";;
		//return 0;
	}
	minm(dp[h],(h+(p1-s)-1)/(p1-s)*t1);
	minm(dp[h],(h+(p2-s)-1)/(p2-s)*t2);
	cout<<dp[h];
}