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 n = 4; Obj[] arr = new Obj[n]; for (int i = 0; i < n; i++) { Obj o = new Obj(); o.a = sc.nextInt(); arr[i] = o; } PriorityQueue que = new PriorityQueue<>((o1, o2) -> o1.t - o2.t); for (int i = 0; i < n; i++) { arr[i].t = sc.nextInt(); que.add(arr[i]); } long t = sc.nextLong(); sc.close(); long ans = 0; while (!que.isEmpty()) { Obj o = que.poll(); long lim = t / o.t; long val = Math.min(lim, o.a); ans += val; t -= val * o.t; } System.out.println(ans); } static class Obj { int a, t; } }