import math

def f(a,b):
    return (a//math.gcd(a,b))*b

def g(a,b,c):
    return f(f(a,b),c)

N=int(input())
a,b,c=map(int,input().split())

if a==b==c:
    print(N//a)
elif len({a,b,c})==2:
    p,q=a,b
    print(N//a+N//b-N//f(a,b))
else:
    print(N//a+N//b+N//c-N//f(a,b)-N//f(b,c)-N//f(c,a)+N//g(a,b,c))