import sys, time, random, heapq, math, itertools, copy from collections import deque, Counter, defaultdict #from sortedcontainers import SortedSet, SortedList from bisect import bisect, bisect_left, bisect_right import heapq as hq from functools import cache, cmp_to_key def debug(*x):print('debug:',*x, file=sys.stderr) sys.setrecursionlimit(300000) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 dir = [(0, 1), (0, -1), (1, 0), (-1, 0)] R, P, Q = mi() A, B, C, D = mi() ans = 0 # ans = min(R//P, min(A, B, C)) # A -= ans # B -= ans # C -= ans # R -= ans * P # debug(ans,R , A, B, C, D) # if A > 0 and B > 0 and C > 0: # Rが足りない # print(ans) # exit() def check(m): # ここからm人合成できるか if A + B + C + D < 3 * m: return False cnt = max(m - A, 0) + max(m - B, 0) + max(m - C, 0) if cnt * Q + m * P > R: return False return True ok = 0 ng = inf while ng - ok > 1: mid = (ok + ng) // 2 if check(mid): ok = mid else: ng = mid debug(ok) print(ans + ok)