human
A frog is initially at position 0 on the number line. The frog has two positive integers a and b. From a position k, it can either jump to position k+a or k-b.

Let f(x) be the number of distinct integers the frog can reach if it never jumps on an integer outside the interval [0, x]. The frog doesn't need to visit all these integers in one trip, that is, an integer is counted if the frog can somehow reach it if it starts from 0.

Given an integer m, find ∑_{i=0}^{m} f(i). That is, find the sum of all f(i) for i from 0 to m.

Input

The first line contains three integers m, a, b (1 ≤ m ≤ 10^9, 1 ≤ a,b ≤ 10^5).

Output

Print a single integer, the desired sum.

Examples

Input

7 5 3

Output

19

Input

1000000000 1 2019

Output

500000001500000001

Input

100 100000 1

Output

101

Input

6 4 5

Output

10

Note

In the first example, we must find f(0)+f(1)+…+f(7). We have f(0) = 1, f(1) = 1, f(2) = 1, f(3) = 1, f(4) = 1, f(5) = 3, f(6) = 3, f(7) = 8. The sum of these values is 19.

In the second example, we have f(i) = i+1, so we want to find ∑_{i=0}^{10^9} i+1.

In the third example, the frog can't make any jumps in any case.
assistant
#Here is Python code to find ∑_{i=0}^{m} f(i).

from collections import defaultdict as ddic, deque, Counter
from itertools import combinations, permutations, product
import sys
sys.setrecursionlimit(10**6)
stdout = sys.stdout
rr = lambda: raw_input().strip()
rri = lambda: int(raw_input())
rrm = lambda: list(map(int, raw_input().strip().split()))

from fractions import gcd
def solve(M, A, B):
    # x -> x+a or x-b
    g = gcd(A, B)
    reachable = [True]
    S = 1
    ans = 1
    for x in xrange(1, 1 + min(M, A+B-1) ):
        if x-A >= 0 and reachable[x - A]:
            reachable.append(True); S+=1
            if x-B >= 0 and not reachable[x-B]:
                queue = deque([x-B])
                reachable[x-B] = True; S+=1
                while queue:
                    node = queue.popleft()
                    if node + A < len(reachable) and not reachable[node+A]:
                        reachable[node+A] = True; S+=1
                        queue.append(node+A)
                    if node - B >= 0 and not reachable[node-B]:
                        reachable[node-B] = True; S+=1
                        queue.append(node-B)
        else:
            reachable.append(False)

        ans += S
    
    def sumtoN(N):
        return N * (N+1) // 2

    # Now to count x = A+B... M
    # ans += sum( 1 + x // g for x in xrange(A+B, M+1))
    todo = M - (A+B) + 1
    if todo < 1: return ans
    bns = 0
    bns += todo
    # ans += sum(x//g for x in A+B ... M)
    base = (A+B) // g
    # base * g + (base+1) * g + ... + (base + q - 1) * g + (base + q) * r
    q, r = divmod(M -(A+B) + 1, g)

    bns += g * ( sumtoN(base+q-1) - sumtoN(base-1) )
    bns += (base+q) * r

    ans += bns
    return ans
    
            

print solve(*rrm())