from collections import deque def solve(R, P, Q, A, B, C, D, value): p_count = 0 m_count = 0 if A - value >= 0: p_count += 1 else: m_count += abs(A - value) if B - value >= 0: p_count += 1 else: m_count += abs(B - value) if C - value >= 0: p_count += 1 else: m_count += abs(C - value) p_count += D if p_count < m_count: return False ans = m_count * Q + value * P return R >= ans def main(): R, P, Q = map(int, input().split()) A, B, C, D = map(int, input().split()) max_count = (A + B + C + D) // 3 low = 0 high = max_count while high - low > 1: mid = (high + low) // 2 if solve(R, P, Q, A, B, C, D, mid): low = mid else: high = mid if solve(R, P, Q, A, B, C, D, high): print(high) else: print(low) if __name__ == "__main__": main() # main2()