import java.util.Arrays; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int x = sc.nextInt(); int a = sc.nextInt(); int y = sc.nextInt(); int b = sc.nextInt(); sc.close(); int m = 40000000; int m2 = 20000000; t += m2; long[] d = new long[m]; Arrays.fill(d, Long.MAX_VALUE); d[m2] = 0; PriorityQueue que = new PriorityQueue(); Node first = new Node(m2, 0); que.add(first); int[] dx = {1, a, -b}; int[] dd = {1, x, y}; while (!que.isEmpty()) { Node cur = que.poll(); if (cur.d > d[cur.v]) { continue; } if (cur.v == t) { System.out.println(d[cur.v]); return; } for (int i = 0; i < 3; i++) { int next = cur.v + dx[i]; if (next < 0 || m <= next) { continue; } long alt = d[cur.v] + dd[i]; if (alt < d[next]) { d[next] = alt; que.add(new Node(next, alt)); } } } } static class Hen { int v, c; public Hen(int v, int c) { this.v = v; this.c = c; } } static class Node implements Comparable { int v; long d; public Node(int v, long d) { this.v = v; this.d = d; } public int compareTo(Node o) { return Long.compare(d, o.d); } } }