from math import gcd N = int(input()) a, b, c = map(int, input().split()) ab_lcm = a * b // gcd(a, b) bc_lcm = b * c // gcd(b, c) ca_lcm = c * a // gcd(c, a) abc_lcm = (ab_lcm * c) // gcd(ab_lcm, c) print(N // a + N // b + N // c - (N // ab_lcm + N // bc_lcm + N // ca_lcm) + N // abc_lcm)