from math import floor n = int(input()) a, b, c = map(int, input().split()) def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) res1 = floor(n / a) + floor(n / b) + floor(n / c) res2 = floor(n / lcm(a,b)) + floor(n / lcm(b,c)) + floor(n / lcm(c,a)) res3 = floor(n / lcm(a,lcm(b,c))) print(res1 - res2 + res3)