#from fractions import gcd #遅い感じ from math import gcd def main(): N = int(input()) A, B, C = map(int, input().split()) lcm = lambda a, b: a * b // gcd(a, b) ab = lcm(A, B) ans = N//A + N//B + N//C + N//lcm(ab,C) - N//ab - N//lcm(B,C) - N//lcm(C,A) print(ans) main()