n = int(input()) a, b, c = map(int, input().split()) L = [a, b, c] from math import gcd from functools import reduce def f(*args): lcm = reduce(lambda x,y: x*y//gcd(x,y), args, 1) return n//lcm import itertools ans = 0 for i in range(1, 4): C = itertools.combinations(L, i) for c in C: if i % 2 == 0: ans -= f(*c) else: ans += f(*c) print(ans)