n = int(input()) a, b, c = [int(x) for x in input().split(' ')] def get_gcd(a, b): # ユークリッド互除法により最大公約数を求める。 if a < b: a, b = b, a if a % b == 0: return b else: return get_gcd(b, a % b) def get_lcm(a, b): # 2数を掛けあわせ、最大公約数で割れば最小公倍数が求まる。 lcm = a * b // get_gcd(a, b) return lcm count_a = n // a count_b = n // b count_c = n // c count_ab = n // get_lcm(a, b) count_bc = n // get_lcm(b, c) count_ac = n // get_lcm(a, c) count_abc = n // get_lcm(get_lcm(a, b), get_lcm(b, c)) print(count_a + count_b + count_c - count_ac - count_bc - count_ab + count_abc)