import math N=int(input()) a,b,c=map(int,input().split()) def lcm(x,y): return x*y//math.gcd(x,y) ans=0 ans+=N//a ans+=N//b ans+=N//c ans-=N//lcm(a,b) ans-=N//lcm(b,c) ans-=N//lcm(c,a) ans+=N//lcm(lcm(a,b),c) print(ans)