from math import gcd N = int(input()) A, B, C = map(int, input().split()) lcm = lambda x, y: x*y//gcd(x, y) print(N//A + N//B + N//C - N//lcm(A, B) - N//lcm(A, C) - N//lcm(B, C) + N//lcm(lcm(A, B), C))