n = int(input()) a, b, c = map(int, input().split()) #import fractions import math from functools import reduce def lcm_base(x, y): #return (x * y) // fractions.gcd(x, y) return (x * y) // math.gcd(x, y) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) ans = n//a + n//b + n//c ans -= n//lcm_base(a, b) + n//lcm_base(b, c) + n//lcm_base(c, a) ans += n//lcm_list([a, b, c]) print(ans)