N = int(input()) a, b, c = map(int, input().split()) def gcd(a, b): if b == 0: return a r = a % b d = gcd(b, r) return d def lcm(a, b): return a*b//gcd(a, b) ans = N // a + N // b + N // c ans -= N // lcm(a, b) + N // lcm(a, c) + N // lcm(b, c) ans += N // lcm(lcm(a, b), c) print(ans)