import strutils proc nextString(): string = while not stdin.endOfFile: let c = stdin.readChar if c == ' ' or c == '\n': break elif c != '\r': result.add(c) proc gcd(x, y: int): int = var a = x var b = y if a < b: swap(a, b) while b > 0: let m = a mod b a = b b = m return a proc lcm(x, y: int): int = x * y div gcd(x, y) proc main(): void = let n, a, b, c = parseInt(nextString()) var ans = 0 for t in [a, b, c]: ans += n div t for t in [lcm(a, b), lcm(b, c), lcm(c, a)]: ans -= n div t ans += n div lcm(lcm(a, b), c) echo ans when isMainModule: main()