def gcd(x,y): while y>0: x,y = y,x%y return x N = int(input()) a,b,c = map(int,input().split()) cnt = N//a+N//b+N//c nab = gcd(a,b) nab = a*b//nab cnt -= N//nab nbc = gcd(b,c) nbc = b*c//nbc cnt -= N//nbc nca = gcd(c,a) nca = c*a//nca cnt -= N//nca nabc = gcd(nab,c) nabc = nab*c//nabc cnt += N//nabc print(cnt)