from fractions import gcd n=int(input()) a,b,c=map(int,input().split()) d=lambda x,y:x*y//gcd(x,y) print(n//a+n//b+n//c+n//d(d(a,b),c)-n//d(a,b)-n//d(a,c)-n//d(c,b))