from math import gcd from heapq import* import math from collections import defaultdict, Counter import sys sys.setrecursionlimit(10 ** 7) MOD = 10 ** 9 + 7 def main(): n = int(input()) a, b, c = map(int, input().split()) def lcm(a, b): return a * b // gcd(a, b) print(int(n // a + n // b + n // c - n // (lcm(a, b)) - n//(lcm(b, c)) - n//(lcm(c, a)) + n//(lcm(a, lcm(b, c))))) if __name__ == '__main__': main()