CodeEff/ECCO huggingface dataset:
# Original solution
n,a,b = list(map(int,input().split()))
for i in range(10**9):
    if i*(a+b)==n:
        print((a*i))
        exit()
    elif i*(a+b)>n:
        t = n-(i-1)*(a+b)
        if t>a:
            t = a
        print(((i-1)*a+t))
        exit()

# Optimized solution
n,a,b = list(map(int,input().split()))
ans = n // (a+b) * a
rem = n % (a+b)
ans += min(rem,a)
print(ans)
# Original solution
n, a, b = list(map(int, input().split()))
ans = []

def add_ball(a, b):
    ball_list = []
    for i in range(a):
        ball_list.append('b')
        if len(ball_list) == n:
            return ball_list
    for j in range(b):
        ball_list.append('r')
        if len(ball_list) == n:
            return ball_list
    return ball_list


for i in range((n // (a + b)) + 1):
    ball_list = add_ball(a, b)
    ans += ball_list

print((ans[:n].count('b')))

# Optimized solution
n, a, b = list(map(int, input().split()))

ans = n // (a + b) * a
rem = n % (a + b)
ans += min(a, rem)  # ansとremを比較することでnの位置よって処理を変えられる

print(ans)
# Original solution
n, a, b = list(map(int, input().split()))

ans = 0
while True:
    if n >= a:
        n -= a
        ans += a
    else:
        ans += n
        break

    if n >= b:
        n -= b
    else:
        break
print(ans)


# Optimized solution
n, a, b = list(map(int, input().split()))

ans = n//(a+b)*a
amari = n-(a+b)*(n//(a+b))
ans += min(amari, a)

print(ans)
# Original solution
N, A, B = list(map(int, input().split()))

b_count = 0
n_count = 0
while n_count < N:
    if n_count + A < N:
        b_count += A
    else:
        b_count += N - n_count
        break
    n_count += A + B
print(b_count)

# Optimized solution
N, A, B = list(map(int, input().split()))

division = N // (A + B)
count = division * A

count += N - division * (A + B) if A > N - division * (A + B) else A
print(count)
# Original solution
n, a, b = list(map(int, input().split()))

al = a
bl = b
cnt = 0
for i in range(n):
    if al != 0:
        cnt += 1
        al -= 1
    elif bl != 0:
        bl -= 1
    
    if al == 0 and bl == 0:
        bl = b
        al = a
    
print(cnt)

# Optimized solution
n, a, b = list(map(int, input().split()))

ans = a * (n // (a + b))
if a < n % (a + b):
    ans += a
else:
    ans += n % (a + b)

print(ans)
# Original solution
N, A, B=list(map(int, input().split(" ")))

sum=0
flag=False
b=0

while True:
  sum=sum+A
  b=b+A
  if sum>N:
    flag=True
    break
  sum=sum+B
  if sum>N:
    break
if flag:
  print((b-(sum-N)))
else:
  print(b)

# Optimized solution
N, A, B=list(map(int, input().split(" ")))

result=A*(N//(A+B))+min(N%(A+B), A)

print(result)
# Original solution
N,A,B=list(map(int,input().split()))
x=[]
for i in range(1,N+A+B):
  for j in range(A):
    x.append("a")
  for k in range(B):
    x.append("b")
   
x=x[:N]
print((x.count("a")))

# Optimized solution
N,A,B=list(map(int,input().split()))
num=N//(A+B)
res=N-num*(A+B)
count=0
if res<=A:
  count=num*A+res
else:
  count=num*A+A
print(count)
# Original solution
n,a,b=list(map(int,input().split()))
m=n//(a+b)
n-=m*(a+b)
print((m*a+min(a,n)))

# Optimized solution
n,a,b=list(map(int,input().split()))
ans=a*(n//(a+b))
ans+=min(a,n%(a+b))
print(ans)
# Original solution
N,A,B = list(map(int, input().split()))
cnt=0
cnt_blue=0
while cnt+A+B<N:
    cnt+=A+B
    cnt_blue+=A
    
print((cnt_blue+min(A,N-cnt)))

# Optimized solution
N,A,B = list(map(int, input().split()))
cnt_blue=A*(N//(A+B))
cnt_all=(A+B)*(N//(A+B))    
print((cnt_blue+min(A,N-cnt_all)))
# Original solution
N,A,B=[int(x) for x in input().rstrip().split()]
 
ans=N//(A+B)
amari=N%(A+B)
if A<=amari:
    amari=A
ans1=ans*A+amari
print(ans1)

# Optimized solution
N,A,B=[int(x) for x in input().rstrip().split()]

num=N//(A+B)
amari=N%(A+B)
tasu=0
if amari<=A:
  tasu=amari
else:
  tasu=A

print((num*A+tasu))
# Original solution
n,a,b = list(map(int,input().split()))
ans = []
while(len(ans) < n):
    for i in range(a):
        if(len(ans) >= n):
            break
        ans.append(1)
    for i in range(b):
        ans.append(0)
print((sum(ans)))

# Optimized solution
n,a,b = list(map(int,input().split()))
print((a*(n//(a+b)) + min(n%(a+b),a)))
# Original solution
n, a, b = list(map(int, input().split()))

x = []
cnt = 0
flag = True
while cnt < n:
    if flag:
        for j in range(a):
            if cnt + j >= n:
                break
            x.append(1)
        cnt += a
        flag = False
    else:
        for j in range(b):
            if cnt + j >= n:
                break
            x.append(0)
        cnt += b
        flag = True

cnt = 0
for i in range(n):
    if x[i] == 1:
        cnt += 1

print(cnt)


# Optimized solution
n, a, b = list(map(int, input().split()))

ans = n // (a + b) * a
rem = n % (a + b)
print((ans + min(rem, a)))
# Original solution
n,a,b = [int(i) for i in input().split()]
#k=n//(a+b)
#ans=a*k+a*(n-(a+b))
ans=0
while n >= 0:
    ans+=min(a,n)
    n-=(a+b)
print(ans)


# Optimized solution
n,a,b = [int(i) for i in input().split()]
if n!=(a+b): print((a*(n//(a+b))+min(a,n%(a+b))))
else: print(a)
# Original solution
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, a, b = list(map(int,ipti().split()))
    ab = a + b

    c = n // ab
    d = n % ab

    ans = c * a + min(a, d)
    print(ans)

if __name__ == '__main__':
    main()

# Optimized solution
n, blue, red = list(map(int, input().split()))

# n / (blue + red) = quot ... rem
quot = n // (blue + red)  # 商 quotient
rem = n % (blue + red)  # 余り remainder

ans = blue * quot + min(blue, rem)

print(ans)
# Original solution
N,A,B=list(map(int,input().split()))
M=0
ans=0
for i in range(10**18):
    if M+A+B<=N:
        M=M+A+B
        ans+=A
    elif M+A<=N:
        ans+=A
        break
    else:
        A=N-M
        ans+=A
        break
print(ans)

# Optimized solution
N,A,B=list(map(int,input().split()))
M=0
ans=0
C=A+B
c=N//C
ans=A*c
if N-C*c<A:
    ans+=N-C*c
else:
    ans+=A
print(ans)
# Original solution
N, A, B = list(map(int, input().split()))

print(((N//(A+B))*A + min(N%(A+B),A)))


# Optimized solution
N, A, B = list(map(int, input().split()))

m = N%(A+B)

print(((N//(A+B))*A + (A if m > A else m)))
# Original solution
n,a,b=list(map(int,input().split()))
x=a
y=b
ct=0
while n>0:
  while n>0 and x>0:
    x=x-1
    n=n-1
    ct=ct+1
  while n>0 and y>0:
    y=y-1
    n=n-1
  x=a
  y=b
print(ct)

# Optimized solution
n,a,b=list(map(int,input().split()))
ct=a+b
num=(n//ct)*a
s=n%ct
result=num
result += min(s,a)
print((int(result)))
# Original solution
N,A,B = list(map(int,input().split()))

ans1 = []
ans2 = []
while len(ans1) <= N:
    for i in range(A):
        ans1.append("b")
    for i in range(B):    
        ans1.append("r")
for i in range(N):
    if ans1[i] == "b":
        ans2.append(ans1[i])
print((len(ans2)))

# Optimized solution
N,A,B = list(map(int,input().split()))

C = N // (A + B)
D = N % (A + B)
ans = A * C

if D >= A:
    ans += A
else:
    ans += D
    
print(ans)
# Original solution
n, a, b = list(map(int, input().split()))

i = 1
cnt = 0
while n > 0:
    if i % 2 != 0:
        if n-a > 0:
            n -= a
            cnt += a
        else:
            cnt += n
            n = 0
    else:
        n -= b
    i += 1

print(cnt)

# Optimized solution
n, a, b = list(map(int, input().split()))

ans = a * (n//(a+b)) + min(n%(a+b), a)
print(ans)
# Original solution
N, A, B = list(map(int, input().split()))
a = 0
b = 0
while True:
  if a + b + A >= N:
    ans = N - b 
    break
  else:
    a += A
    if a + b + B >= N:
      ans = a
      break
    else:
      b += B
print(ans)

# Optimized solution
N, A, B = list(map(int, input().split()))
ans  = (N//(A+B))*A
if N%(A+B)<=A:
  ans += N%(A+B)
elif N%(A+B) !=0:
  ans += A
print(ans)
# Original solution
N,A,B = list(map(int, input().split()))
L = []
b = 0
ans = 0
cnt = 0

while True:
  if A == 0: break

  L.append(A)
  b += A
  cnt += A
  if cnt > N:
    ans = b - (cnt - N)
    break

  L.append(B)
  cnt += B
  if cnt > N:
    ans = b
    break

print(ans)

# Optimized solution
N,A,B = list(map(int, input().split()))
L = []
b = 0
ans = 0

if A == 0:
  ans = 0
elif N < A:
  ans = N
elif N < A+B:
  ans = A
else:
  x = N // (A+B)
  y = N % (A+B)
  ans = A * x + min(y, A)

print(ans)
# Original solution
N, A, B = list(map(int, input().split()))

all_count = 0
blue_count = 0

while all_count < N:
    if all_count + A >= N:
        blue_count += N - all_count
        break
    all_count += A
    all_count += B
    blue_count += A

print(blue_count)

# Optimized solution
N, A, B = list(map(int, input().split()))

operation_count = N // (A+B)
blue_count = A * operation_count
if N % (A+B) > 0:
    rest = N % (A+B)
    blue_count += min([rest, A])

print(blue_count)
# Original solution
[N, A, B]= list(map(int, input().split()))

ball = []
ans = 0
for k in range(N//(A+B)) :
    for i in range(A) :
        ball.append('b')
    for j in range(B) :
        ball.append('r')

mod = N % (A+B)
for l in range(N % (A+B)) :
    for m in range(A) :
        if mod > 0 :
            ball.append('b')
            mod -= 1
        else :
            break
    for n in range(B):
        if mod > 0 :
            ball.append('r')
            mod -= 1
        else :
            break

#print(ball)
ans = ball.count('b')
print(ans)

# Optimized solution
N, A, B= list(map(int, input().split()))
ans = 0

div = N//(A+B) * A
mod = N % (A+B)
ans = div + min(mod, A)

print(ans)
# Original solution
N, A, B = list(map(int, input().split()))

answer = N // (A + B) * A
if  N % (A + B) <= A:
    answer += N % (A + B)
else:
    answer += A

print(answer)

# Optimized solution
N, A, B = list(map(int, input().split()))

print((N // (A + B) * A + min(A, N % (A + B))))
# Original solution

N, A, B = list(map(int, input().split()))
i = 0
b = 0
r = 0
while i < N:
    if (i+A <= N):
        b += A
        i += A
    elif(i+A > N):
        b += N-i
        break
    if (i+B <= N):
        r += B
        i += B
    elif(i+B > N):
        r += N-i
        break        
print(b)


# Optimized solution

N, A, B = list(map(int, input().split()))
i = 0
b = 0
r = 0

c = N//(A+B)
#print(c)
d = N%(A+B)
#print(d)
if d <= A:
    b = c*A + d
else:
    b = (c+1)*A
print(b)
# Original solution


n, a, b = list(map(int, input().split()))
ans = n // (a + b) * a
rem = n % (a + b)
ans += min(rem, a)
print(ans)

# Optimized solution
n, a, b = list(map(int, input().split()))

ans1 = n//(a + b) * a
ans2 = min(n % (a + b), a)
print((ans1 + ans2))
# Original solution
N,A,B = list(map(int,input().split()))
balls = []
odd = 1
while len(balls)<=N:
    if odd == 1:
        for i in range(1,A+1):
            balls = balls + ["b"]
        odd = 0
    else:
        for i in range(1,B+1):
            balls = balls + ["r"]
        odd = 1
balls = balls[:N]
print((balls.count("b")))

# Optimized solution
N,A,B = list(map(int,input().split()))
balls = A + B
N_surplus = N%balls
if N_surplus < A:
    blues = (N//balls)*A + N_surplus
else:
    blues = (N//balls)*A + A
print(blues)
# Original solution
def main():
    N, A, B = (int(i) for i in input().split())
    ans = (N//(A+B)) * A
    less = N - (N//(A+B)) * (A+B)
    print((ans + min(less, A)))


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    N, A, B = (int(i) for i in input().split())
    ans = (N//(A+B)) * A
    print((ans + min(N % (A+B), A)))


if __name__ == '__main__':
    main()
# Original solution
n, a, b = list(map(int, input().split()))
a_count = 0
n_count = 0

while n_count < n:
    for i in range(a):
        if n_count >= n:
            break
        a_count += 1
        n_count += 1
    n_count += b

print(a_count)


# Optimized solution
n, a, b = list(map(int, input().split()))
ans = n // (a+b)*a
rem = n % (a+b)
ans += min(rem, a)
print(ans)
# Original solution
n, b, r = list(map(int, input().split()))
ans = 0

while n > 0:
    ans += min(n, b)
    n -= b + r

print(ans)


# Optimized solution
n, b, r = list(map(int, input().split()))

ans = n // (b + r) * b
n = n % (b + r)

ans += min(n, b)

print(ans)
# Original solution
n,a,b=list(map(int,input().split()))
sum=0
while n>sum:
    sum+=(a+b)
x=sum//(a+b)-1
left=n-x*(a+b)
if left<=a:
    print((a*x+left))
else:
    print((a*x+a))

# Optimized solution
n,a,b=list(map(int,input().split()))
x=n//(a+b)
left=n-x*(a+b)
if left<=a:
    print((a*x+left))
else:
    print((a*x+a))
# Original solution
import sys

n,a,b=list(map(int,input().split()))

if a == 0:
    print((0))
    sys.exit()

lst = []
is_blue = True
count = 0
for i in range(n):
    if is_blue:
        lst.append('b')
        count += 1
        if count == a:
            is_blue = False
            count = 0
    else:
        lst.append('r')
        count += 1
        if count == b:
            is_blue = True
            count = 0

result = list([x for x in lst if x == 'b'])
print((len(result)))

# Optimized solution
n,a,b = list(map(int,input().split()))

ans = n // (a + b) * a
rem = n % (a + b)
ans += min(rem, a)
print(ans)
# Original solution
N,A,B= list(map(int, input().split()))

s=0
c=0
while c+A<N:
    c=c+A+B
    s=s+A

if c>=N:
    print(s)
else:
    print((s+N-c))

# Optimized solution
N,A,B= list(map(int, input().split()))

c=(A+B)*(N//(A+B))
s=A*(N//(A+B))

if c+A<=N:
    print((s+A))
else:
    print((s+N-c))
# Original solution
n,a,b=list(map(int, input().split()))

balls= 0
blue = 0

for i in range(10**18):
  if i % 2 == 0:
    if (balls + a) >= n:
      fill = n - balls
      balls = balls + fill
      blue = blue + fill
      break      
    balls = balls + a
    blue = blue + a
  else:
    if (balls + b) >= n:
      fill = n - balls
      balls = balls + fill
      break
    balls = balls + b

print(blue)

# Optimized solution
n,a,b=list(map(int, input().split()))

balls= 0
blue = 0

time = n // (a+b)
tmp = n % (a+b)
if tmp < a:
  blue = time*a + tmp
else:
  blue = (time+1)*a

print(blue)
# Original solution
a=input().split()
N,A,B=int(a[0]),int(a[1]),int(a[2])
st_a,st_b='',''
for i in range(A):
  st_a+='b'
for i in range(B):
  st_b+='r'
sum=0
b=''
while sum<=N:
  b+=st_a
  sum+=A
  if(sum>=N):
    break
  b+=st_b
  sum+=B
c=b[0:N]
print((c.count('b')))

# Optimized solution
a=input().split()
N,A,B=int(a[0]),int(a[1]),int(a[2])
b=int(N/(A+B))
ans=int(A*b)
if(N-b*(A+B)<=A):
    ans=ans+N-b*(A+B)
else:
    ans+=A
print((int(ans)))
# Original solution
import sys
N, A, B = list(map(int, input().split()))
count = 0
while True:
    for i in range(A):
        N -= 1
        count += 1
        if N == 0:
            print(count)
            sys.exit()
    for j in range(B):
        N -= 1
        if N == 0:
            print(count)
            sys.exit()

# Optimized solution
N, A, B = list(map(int, input().split()))
answer = N // (A+B) * A
remainder = N % (A+B)
answer += min(remainder, A)
print(answer)
# Original solution
N, A, B = list(map(int, input().split()))
list = []
count = 0

if A > N:
  print(N)
  
if A < N and A+B > N:
  print(A)
  
else:
  while len(list) <= N:
    i = 0
    for i in range(A):
      list.append('b')
      
    if len(list) <= N:
      i = 0
      for i in range(B):
        list.append('r')

  for i in range(N):
    if list[i] == 'b':
      count += 1
  print(count)
  

# Optimized solution
N, A, B = list(map(int, input().split()))

a = N // (A+B)

if N % (A+B) >= A:
  print((a*A+A))
  
else:
  print((a*A + N % (A+B)))
# Original solution
# n = int(input())
n, a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
row = []
while len(row) < n:
    i = 0
    while i != a:
        row.append("b")
        # print(i)
        i += 1

    j = 0
    while j != b:
        row.append("r")
        # print(j)
        j += 1

cnt = 0
k = 1
for r in row:
    if k == n+1:
        break
    k += 1

    if r == "b":
        cnt += 1

print(cnt)

# Optimized solution
n, a, b = list(map(int, input().split()))

x = n//(a+b)

print((a*x + min(a, n%(a+b))))
# Original solution
def main():
    n, a, b = list(map(int, input().split()))

    leng = 0
    ans = 0

    while n >= leng:
        if a < (n - leng):
            ans += a
            leng += (a + b)
        else:
            ans += n - leng
            leng += (a + b)

    print(ans)



    # if a >= n:
    #     print(n)
    # else:
    #     print(a)


if __name__ == '__main__':
    main()

# Optimized solution
def main():
    n, a, b = list(map(int, input().split()))

    tmp = n // (a + b)

    if n - tmp * (a + b) > a:
        print((tmp * a + a))
    else:
        print((tmp * a + n - tmp * (a + b)))

    # TLE
    # while n >= leng:
    #     if a < (n - leng):
    #         ans += a
    #         leng += (a + b)
    #     else:
    #         ans += n - leng
    #         leng += (a + b)

    # if a >= n:
    #     print(n)
    # else:
    #     print(a)


if __name__ == '__main__':
    main()
# Original solution
n, a, b = (int(x) for x in input().split())
if a == 0:
    print('0')
    exit()
count_a = n // (a + b)
leave = n % (a + b)
if leave >= a: leave = a
ans = a * count_a + leave
print(ans)

# Optimized solution
# 高橋くんが根性ありすぎるので, ループではTLE
# 単純に商と剰余の和と思いがちだが, そうでないことに注意
n, a, b = (int(x) for x in input().split())
if a == 0:
    print('0')
    exit()
count_a = n // (a + b)
leave = n % (a + b)
# 剰余がaを超えていた場合, aにする
if leave >= a: leave = a
ans = a * count_a + leave
print(ans)
# Original solution
n, b, r = list(map(int, input().split()))

num = 0
res_b = 0
cnt = n//2 + n%2

for _ in range(cnt):
  num += b
  if num > n:
    res_b += b - (num - n)
  else:
    res_b += b
      
  num += r

  if num > n:
    break
  
print(res_b)

# Optimized solution
n, b, r = list(map(int, input().split()))

cnt_blk = n // (b+r)
res_b = cnt_blk*b
num = cnt_blk*(b+r) + b

if num > n:
  res_b += b - (num - n)
else:
  res_b += b
      
print(res_b)
# Original solution
List = list(map(int, input().split()))

Set0 = List[0]//(List[1]+List[2])
E = List[0] - (List[1]+List[2])*Set0

if E >= List[1]:
    Blue = Set0 * List[1] + List[1]
else:
    Blue = Set0 * List[1] + E

print(Blue)

# Optimized solution
List = list(map(int, input().split()))

Set0 = List[0]//(List[1]+List[2])

Blue = Set0 * List[1] + min(List[0] - (List[1]+List[2])*Set0, List[1])

print(Blue)
# Original solution
n,a,b=list(map(int,input().split()))
if a==0:
  print("0")
  exit()
ans = 0
while n>0:
  if n>=a:
    ans += a
    n -= a
  else:
    ans += n
    n = -1
  n -= b
print(ans)

# Optimized solution
n,a,b=list(map(int,input().split()))
if a==0:
  print("0")
  exit()
tmp1 = n // (a+b)
tmp2 = n-(tmp1*(a+b))
if tmp2 >= a:
  print(((tmp1*a)+a))
else:
  print(((tmp1*a)+tmp2))
# Original solution
N, A, B = list(map(int, input().split()))

total_list = []
count = 0
break_flag = False
for i in range(int(10e100)):
    if break_flag:
        break
    for i in range(A):
        total_list.append("b")
        if len(total_list) <= N:
            count += 1
        else:
            break_flag = True
            break
    for i in range(B):
        total_list.append("r")
        if len(total_list) >= N:
            break_flag = True
            break
    if len(total_list) >= N:
        break

print(count)

# Optimized solution
N, A, B = list(map(int, input().split()))

amari = N % (A + B)
sho = N // (A + B)

blue_num = 0

if amari < A:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + A

print(blue_num)
# Original solution
n,a,b = list(map(int,input().split()))
l = []
while True:
    for _ in range(a):
        l.append("r")
    for _ in range(b):
        l.append("b")

    if len(l) >= n:
        print((l[0:n].count("r")))
        exit ()

# Optimized solution
n,a,b = list(map(int,input().split()))
x = -(-n//(a+b))
total = (a+b)*(x-1)
total_a = a*(x-1)
if n - total >= a:
    print((total_a + a))
else:
    print((total_a + (n-total)))
# Original solution
import math
N, A, B = (int(x) for x in input().split(' '))
ans = 0
#
for i in range(N):
  if i % (A+B) < A:
    ans += 1
#結果出力
print(ans)

# Optimized solution
import math
N, A, B = (int(x) for x in input().split(' '))
tmp = A * math.floor(N/(A+B))

if ( N % (A+B) ) > A:
  print((tmp+A)) 
else:
  print((tmp+( N % (A+B))))
# Original solution
n, a, b = list(map(int, input().split()))
red = 0 ; blue = 0
while n >= 0 :
    if n > a :
        n -= a
        blue += a
    else :
        blue += n
        break
    if n > b :
        n -= b
        red += b
    else :
        red += b
        break
print(blue)


# Optimized solution
n, a, b = list(map(int, input().split()))
red = 0 ; blue = 0
if n >= a + b :
    stack = n // (a+b)
    red += b * stack
    blue += a * stack
    n -= (a+b) * stack
if n > a :
    n -= a
    blue += a
else :
    blue += n
if n > b :
    n -= b
    red += b
else :
    red += n
print(blue)
# Original solution
# ABC158 B - Count Balls

N,A,B = list(map(int,input().split()))
A_A = 0
B_B = 0
for i in range(N):
    if N >= A:
        A_A +=A
        N -=A
    else:
        A_A +=N
        break
    if N >= B:
        B_B +=B
        N -=B
    else:
        B_B +=N
        break
print(A_A)
    


# Optimized solution
# ABC158 B - Count Balls

M,A,B = list(map(int,input().split()))
import math
C = math.floor(M/(A+B))
N = M%(A+B)
E = C*A
A_A = 0
B_B = 0
for i in range(N):
    if N >= A:
        A_A +=A
        N -=A
    else:
        A_A +=N
        break
    if N >= B:
        B_B +=B
        N -=B
    else:
        B_B +=N
        break
print((A_A+E))
# Original solution
# ABC158 B - Count Balls

M,A,B = list(map(int,input().split()))
import math
C = math.floor(M/(A+B))
N = M%(A+B)
E = C*A
A_A = 0
B_B = 0
for i in range(N):
    if N >= A:
        A_A +=A
        N -=A
    else:
        A_A +=N
        break
    if N >= B:
        B_B +=B
        N -=B
    else:
        B_B +=N
        break
print((A_A+E))
    


# Optimized solution
# ABC158 B - Count Balls

M,A,B = list(map(int,input().split()))
import math
C = math.floor(M/(A+B))
N = M%(A+B)
E = C*A

if N >= A:
    E+=A
else:
    E+=N
print(E)
# Original solution
import sys
n, a, b = list(map(int, input().split()))
if a == 0 or n == 0:
    print((0))
    sys.exit()
for i in range(n //(a + b) + 1):
    if (a + b) * i <= n < (a + b) * (i + 1):
        j = i
        break
if n - (a + b) * j >= a:
    print((a * j + a))
    sys.exit()
else:
    print((a * j + n- (a + b)*j ))
    sys.exit()

# Optimized solution
import sys
n, a, b = list(map(int, input().split()))
if a == 0 or n == 0:
    print((0))
    sys.exit()
j = n //(a + b)

if n - (a + b) * j >= a:
    print((a * j + a))
    sys.exit()
else:
    print((a * j + n- (a + b)*j ))
    sys.exit()
# Original solution
n,a,b=list(map(int,input().split()))
p=n//(a+b)
if n%(a+b)==0:
	r=0
elif n%(a+b)>=a:
	r=a
else:
	for i in range(a):
		if n%(a+b)==i:
			r=i
ans=p*a+r
print(ans)

# Optimized solution
n,a,b=list(map(int,input().split()))
p=n//(a+b)
if n%(a+b)==0:
	r=0
elif n%(a+b)>=a:
	r=a
else:
	r=n%(a+b)
ans=p*a+r
print(ans)
# Original solution
n,a,b = list(map(int,input().split()))
blue = ''.join(['b' for i in range(a)])
red = ''.join(['r' for i in range(b)])
s = str()
while len(s) < n:
    s += blue
    if len(s) >= n:
        break
    s += red
    
print((s[:n].count('b')))

# Optimized solution
n,a,b = list(map(int,input().split()))
ans = int(n / (a + b))
rem = n % (a + b)
if rem > a:
    print((ans * a + a))
else:
    print((ans * a + rem))
# Original solution
N,A,B=list(map(int,input().split()))
n=0
S=''
flag=False
while True:
    for i in range(A):
        S+='b'
        n+=1
        if n==N:
            flag=True
            break
    if flag:
        break
    
    for i in range(B):
        S+='r'
        n+=1
        if n==N:
            flag=True
            break
    if flag:
        break
    
cnt=0
for i in S:
    if i=='b':
        cnt+=1

print(cnt)

# Optimized solution
N,A,B=list(map(int,input().split()))
cycle=A+B
a=N//cycle
b=N%cycle
if b>A:
    b=A
cnt=a*A+b
print(cnt)