A,B,C,D,E=map(int,input().split()) import math ptA,ptB=A+B,C+D S=math.gcd(ptA,ptB)*(ptA)*(ptB) cnt_cir=0 ans=0 for i in range(S): if i%ptA