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