def main(): try: import pypyjit pypyjit.set_param('max_unroll_recursion=-1') except: pass try: import sys sys.setrecursionlimit(10**7) except: pass from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum import heapq from bisect import bisect_left, bisect_right import copy from collections import deque,Counter,defaultdict from itertools import permutations,combinations from decimal import Decimal,ROUND_HALF_UP #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP) from functools import lru_cache, reduce #@lru_cache(maxsize=None) from operator import add,sub,mul,xor,and_,or_ INF = 10**18 mod1 = 10**9+7 mod2 = 998244353 #DecimalならPython H,W,La,Lb,Ka,Kb = map(int, input().split()) ans = 0 delete = 0 if H >= W: W2 = W while H > 0 and W2 > 0: ans += 1 W2 -= Lb delete += Kb H -= delete//W delete %= W while H > 0: ans += 1 H -= La delete += Ka H -= delete//W delete %= W else: H2 = H while W > 0 and H2 > 0: ans += 1 H2 -= La delete += Ka W -= delete//H delete %= H while W > 0: ans += 1 W -= Lb delete += Kb W -= delete//H delete %= H print(ans) if __name__ == '__main__': main()