N = int(input()) a,b,c = map(int,input().split()) def gcd(a,b): while True: r = a % b a = b b = r if r == 0: return a x = a * b // gcd(a,b) y = b * c // gcd(b,c) z = c * a // gcd(a,c) w = x * y // gcd(x,y) print(N // a + N // b + N // c - N // x - N // y - N // z + N // w)