import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.StringTokenizer;

public class Solution implements Runnable {
	
	private PrintWriter out;
	private BufferedReader in;
	private StringTokenizer st;
	private int t;
	private int c1;
	private int c2;
	private int a1;
	private int a2;
	
	private void solve() throws Exception {
		t = nextInt();
		c1 = nextInt();
		c2 = nextInt();
		a1 = nextInt();
		a2 = nextInt();
		long l = -1;
		long r = 10000000000L;
		while (l + 1 < r) {
			long m = (l + r) / 2;
			if (check(m)) {
				r = m;
			} else {
				l = m;
			}
		}
		out.println(r);
	}
	
	private boolean check(long time) {
		long busy = 0;
		int cnt1 = 0;
		int cnt2 = 0;
		int cnt = a1 + a2;
		for (int i = 0; i < cnt; i++) {
			long start = time - t * (cnt - i);
			if (start < 0) {
				return false;
			}
			long finish = t * (i + 1);
			busy = Math.max(busy, finish);
			long available = start - busy;
			if (available >= c2 && cnt2 < a2) {
				busy += c2;
				cnt2++;
			} else if (available >= c1 && cnt1 < a1) {
				busy += c1;
				cnt1++;
			} else {
				return false;
			}
		}
		return true;
	}

	public void run() {
		try {
			solve();
		} catch (Exception e) {
			apstenu(e);
		} finally {
			out.close();
		}
	}

	private void apstenu(Exception e) {
		e.printStackTrace();
		System.exit(239);
	}
	
	private String nextToken() throws Exception {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			st = new StringTokenizer(line);
		}
		return st.nextToken();
	}
	
	private int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}
	
	private Solution(String name) {
		try {
			out = new PrintWriter(new FileWriter(name + ".out"));
			in = new BufferedReader(new FileReader(name + ".in"));
			st = new StringTokenizer("");
		} catch (Exception e) {
			apstenu(e);
		}
	}
	
	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		new Thread(new Solution("coffin")).start();
	}
}
