mod = 998244353 def main(): import sys input = sys.stdin.readline H, W, ah, aw, bh, bw = map(int, input().split()) ok = H + W + 1 ng = 0 mid = (ok + ng) // 2 while ok - ng > 1: flg = 0 for num_h in range(mid + 1): num_w = mid - num_h if min(H, ah * num_h) * min(W, aw * num_w) + bh * num_h + bw * num_w >= H*W: flg = 1 break if flg: ok = mid else: ng = mid mid = (ok + ng) // 2 print(ok) if __name__ == '__main__': main()