import strutils proc input: string = while true: let t = stdin.readChar if t.isDigit: result.safeAdd t elif t == '\r': discard else: break proc gcd(x0, y0: int): int = var (x, y) = (x0, y0) if x < y: swap(x, y) while y > 0: let r = x mod y (x, y) = (y, r) result = x let N, a, b, c = input().parseInt var arr = @[a] cnt = 0 if b mod a != 0: arr.add b if c mod a != 0 and c mod b != 0: arr.add c for v in arr: cnt += N div v if arr.len != 1: var arr2 = newSeq[int]() for i in 0 ..< (if arr.len == 3: 3 else: 1): let (x, y) = (arr[i], arr[(i + 1) mod arr.len]) arr2.add x * y div gcd(x, y) for v in arr2: cnt -= N div v if arr.len != 2: let ab = (a * b) div gcd(a, b) cnt += N div (ab * c div gcd(ab, c)) echo cnt