from math import lcm N = int(input()) A = [int(x) for x in input().split()] result = 0 for i in range(1, 8): g = lcm(*(A[j] for j in range(3) if i >> j & 1)) s = 1 if i.bit_count() % 2 == 1 else -1 result += N // g * s print(result)