CodeEff/ECCO huggingface dataset:
# Original solution
n,a,b = list(map(int, input().split()))

b_counter = 0
total = 0
count = 0
color = "test"


while total < n:
  count += 1
  if (count % 2) == 1: #blue
    color="B"
    b_counter += a
    total += a
  else: #red
    color = "R"
    total += b
    
if color == "B":
  b_counter = b_counter - (total - n)
  print(b_counter)
else:
  print(b_counter)

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

if (a+b) == 0:
  print((0))
else:
  trial_num = n // (a + b)
  amari = n % (a + b)
  
  if a == 0:
    print((0))
  else:
    if a <= amari:
      print((trial_num*a + a))
    else:
      print((trial_num*a + amari))
# Original solution
N, A, B = list(map(int, input().split()))
count_all = 0
count_blue = 0

is_blue = True

while True:
    if is_blue:
        if count_all + A > N:
            count_blue += A - ((count_all + A) - N)
            break

        count_all += A
        count_blue += A
        is_blue = not is_blue
    else:
        if count_all + B > N:
            break
        count_all += B
        is_blue = not is_blue

print(count_blue)

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

AB = A+B
C = N // AB
n = N - AB * C

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

l=[]
while len(l) < n:
    for i in range(a):
        if len(l) < n:
            l.append('b')
        else:
            break
    for j in range(b):
        if len(l) < n:
            l.append('r')
        else:
            break

print((l.count('b')))

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

q=n//(a+b)
mod=n%(a+b)
ans=a*q
if a < mod:
    ans+=a
else:
    ans+=mod
print(ans)
# Original solution
li = list(map(int,input().split()))
out = int(li[0] / (li[1] + li[2])) * li[1]
remain = li[0] - int(li[0] / (li[1] + li[2])) *  (li[1] + li[2])
if(remain > li[1]):
    out += li[1]
else:
    out += remain
print(out)

# Optimized solution
N, A, B = list(map(int, input().split()))
n = int(N / (A + B))
m = min(N - n * (A + B), A)
print((n * A + m))
# Original solution
N,A,B=list(map(int,input().split()))
a=[]
while len(a) < N:
    for i in range(A):
        a.append("x")
    for j in range(B):
        a.append("y")
ans=a[:N]
print((ans.count("x")))




# Optimized solution
N,A,B=list(map(int,input().split()))
K=N//(A+B)
print((K*A+min(A,N%(A+B))))
# Original solution
N,A,B=list(map(int,input().split()))
count=0
for i in range(N):
    k=i%(A+B)
    if k<A:
        count+=1
print(count)

# Optimized solution
N,A,B=list(map(int,input().split()))
count=0
k=N%(A+B)
add=0
if k<A:
    add=k
else:
    add=A
print((N//(A+B)*A+add))
# Original solution
N, A, B = (int(x) for x in input().split())
s = ""
while True:
    for i in range(A):
        if len(s) != N:
            s += "b"
        else:
            break

    for j in range(B):
        if len(s) != N:
            s += "r"
        else:
            break
    if len(s) == N:
        break

print((s[:N].count("b")))

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

a, b = divmod(N, (A + B))
if A <= b:
    print(((a+1) * A))
else:
    print(((a * A) + b))
# Original solution
N, A, B = list(map(int, input().split()))
list = []
count = 0

for _ in range(0, N):
    for _ in range(0, A):
        list.append('b')
    for _ in range(0, B):
        list.append('r')

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


print(count)


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

x = N // (A + B)
y = N % (A + B)


if y <= A:
    print((x * A + y))
else:
    print((x*A+A))
# Original solution
N, A, B = list(map(int, input().split()))
capacity = N
is_a = True
cnt = 0

while capacity > 0:
    if is_a:
        ball = A
        cnt += min(capacity, ball)
    else:
        ball = B

    is_a = not is_a
    capacity -= min(capacity, ball)

print(cnt)


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

combo = A + B
num_of_combo = N // combo
remaining = N - combo * num_of_combo

print((num_of_combo * A + min(remaining, A)))
# Original solution
S = input().split(" ")

n = int(S[0])
blue = int(S[1])
countB = 0
red = int(S[2])
countR = 0
shuki = blue + red
sh = 0
for i in range(1,n+1):
  amari = i % shuki
  if amari >=1 and amari <= blue:
    countB = countB +1
  else:
    countR = countR + 1
print(countB)

# Optimized solution
N, A, B = list(map(int, input().split()))
an = N // (A+B) * A
rem = N % (A+B)
an += min(rem,A)
print(an)
# Original solution

def main():
    n, a, b = list(map(int, input().split()))
    flag = True
    res = n
    count = 0
    if a == 0:
        print((0))
        exit(0)
    count = res // (a + b)
    res = n - ( ( a + b ) * count )
    a_count = 0
    while True:
        if a_count == a or res == 0:
            break
        res -= 1
        a_count += 1
           
    print(( a_count + a * count))
    
    


if __name__ == "__main__":
    main()

# Optimized solution

def main():
    n, a, b = list(map(int, input().split()))
    res = n
    count = 0
    if a == 0:
        print((0))
        exit(0)
    count = res // (a + b)
    res = n - ( ( a + b ) * count )
    if a < res:
        print((a * (count + 1)))
    else:
        print((a * count + res))
    


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

count = 0
while(True):
    val = n - a

    if val > 0:
        n = val
        count += a
    else:
        count = count + a  +  val
        break
    n -= b
    if n <= 0:
        break
print(count)


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

ans = n // (a + b) * a
alp = min([n % (a + b), a])

print((ans + alp))
# Original solution
a,b,c=list(map(int,input().split()))
l=[]
k=0
for i in range(a):
    for g in range(b):
        l.append("1")
    for g in range(c):
        l.append("2")
for j in range(a):
    if l==[]:
        k=0
        break
    elif l[j]== "1":
        k+=1
print(k)

# Optimized solution
n,a,b = list(map(int, input().split()))
g = n//(a+b)
k = n-(a+b)*g
if k >= a:
    print((a+a*g))
else:
    print((a*g + k))
# Original solution
N,A,B=list(map(int, input().split()))
a=[]
c=1
y=0
C=int(N/(A+B)+1)
for i in range(A):
	a.append(1)
for j in range(B):
	a.append(0)
b=a.copy()
for k in range(C):
	a.extend(b)
for p in a:
	if N>=c:
		if p==1:
			y+=1
	c+=1
print(y)

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

#for i in range(N):
while N>=0:
	for j in range(A):
		if N==0:
			break
		C+=1
		N-=1
	for k in range(B):
		N=N-1
print(C)
# Original solution
if __name__ == '__main__':
    n, a, b = tuple([int(s) for s in input().split()])
    res = 0

    while n > 0:
        res += min([a, n])
        n -= a
        n -= b

    print(res)


# Optimized solution
if __name__ == '__main__':
    n, a, b = tuple([int(s) for s in input().split()])
    div = n // (a + b)
    mod = n % (a + b)

    print((a * div + min([a, mod])))
# Original solution
i = list(map(int, input().split()))

N = int(i[0])
A = int(i[1])
B = int(i[2])

l = []

while len(l) < N:
    for i in range(A):
        if len(l) == N:
            break
        l.append(0)

    for i in range(B):
        if len(l) == N:
            break
        l.append(1)
        
print((l.count(0)))

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

N = int(i[0])
A = int(i[1])
B = int(i[2])

count_blue = 0

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

if amari > A:
    count_blue = A * syou + A
else:
    count_blue = A * syou + amari

print(count_blue)
# Original solution
# coding: utf-8

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

x=n//(a+b)*a       # (a+b)個までで入っている青の数（入力例1の場合，3個）
y=n%(a+b)       # nを(a+b)で割った余り（入力例1の場合，1個）

for i in range(y):
    x += 1
    cnt += 1
    
    if cnt == a:
        break

print(x)

# Optimized solution
# coding: utf-8

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

x=n//(a+b)*a       # a+b個までで入っている青の数（入力例1の場合，3個）
y=n%(a+b)       # nを(a+b)で割った余り（入力例1の場合，1）

if y>a:
    x = x + a
else:
    x = x + y

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

q = int(N / (A+B))
r = N%(A+B)
print(((q+1)*A if r>A else q*A+r))

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

q = int(N / (A+B))
r = N%(A+B)
#print((q+1)*A if r>A else q*A+r)
print((q*A + min(A, r)))
# Original solution
n, a, b = list(map(int, input().split(" ")))

blue_count = 0
while n != 0:
    # 青
    if n > a:
        n -= a
        blue_count += a
    else:
        blue_count += n
        n = 0
    if n > b:
        n -= b
    else:
        n = 0

print(blue_count)


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

blue_count = a * (n // (a + b))
n -= (a + b) * (n // (a + b))
if n >= a:
    blue_count += a
else:
    blue_count += n
print(blue_count)
# Original solution
n, a, b = list(map(int, input().split()))

total = 0
blue = 0

for i in range(int(10e100)):
    if i % 2 == 0:  # blue
        total += a
        blue += a
        if total >= n:
            mod = total - n
            print((blue - mod))
            break
    else:  # red
        total += b
        if total >= n:
            print(blue)
            break

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

x, mod = divmod(n, a + b)

if x == 0:
    print((min(a, n)))
else:
    print((a * x + min(mod, a)))
# Original solution
N, A, B = list(map(int, input().split()))

ans = 0 
num = 0
while True:
  ans += A
  num += A
  if num >= N:
    ans -= num-N
    break
  num += B
  if num >= N:
    break
    
print(ans)

# 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
# -*- coding: utf-8 -*-
import math
def main():
    N,A,B = list(map(int,input().split()))
    ans0 = N//(A+B)
    ans1 = A*ans0
    ans2 = (N-(A+B)*ans0)
    if ans2 <= 0:
        ans2 = 0
    if ans2 < A:
        ans1 += ans2
    elif ans2 >= A:
        ans1 += A

    print(ans1)

if __name__ == '__main__':
    main()

# Optimized solution
# -*- coding: utf-8 -*-
def main():
    N,A,B = list(map(int,input().split()))
    ans0 = N//(A+B)
    ans1 = A*ans0
    ans2 = (N-(A+B)*ans0)
    if ans2 <= 0:
        ans2 = 0
    ans1 += min(ans2,A)
    print(ans1)
if __name__ == '__main__':
    main()
# Original solution

def main():
    N, A, B = list(map(int, input().split()))

    ans = 0
    a = 0
    b = 0
    for _ in range(N + 1):
        if (a < A) and (b == 0):
            ans += 1
            a += 1
        elif (a == A) and (b == 0):
            a = 0
            b += 1
        elif b < B:
            b += 1
        elif b == B:
            b = 0
    print(ans)
    return 0
if __name__ == '__main__':
    main()

# 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 = 0
while True:
  if N >= A:
    ans += A
    N -= A + B
  else:
    ans += max(N, 0)
    break
print(ans)
  

# Optimized solution
N, A, B = list(map(int, input().split()))
ans = (N // (A+B)) * A + min(A, N%(A+B))
print(ans)
# Original solution
nums = input().split(" ")
N = int(nums[0])
A = int(nums[1])
B = int(nums[2])
time = 0

while N > (A + B):
  N -= (A + B)
  time += 1
if N - A <= 0:
  print((N + A*time))
else:
  print((A + A*time))

# Optimized solution
nums = input().split(" ")
N = int(nums[0])
A = int(nums[1])
B = int(nums[2])

time = int(N / (A + B))

if time == 0 or (time == 1 and N / (A + B) == 1):
  if N - A <= 0:
    print(N)
  else:
    print(A)
else:
  N -= (A + B) * time
  if N - A <= 0:
    print((N + A*time))
  else:
    print((A + A*time))
# Original solution
N, A, B = list(map(int, input().split()))

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

print(ans)


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

d, m = divmod(N, A + B)
ans = A * d + min(m, A)
print(ans)
# Original solution
from math import ceil,log
N=int(eval(input()))
A=[int(i) for i in input().split()]
def f(A):
    dp=[[0]*16 for i in range(N)]
    for i in range(16):
        dp[N-1][i]=i
    for n in range(N-2,-1,-1):
        nx=ceil(log(A[n]/A[n+1])/log(4)) #A
        for x in range(16):
            dx=nx+x
            if dx <=15:
                #print(max(0,dx))
                dp[n][x]=dp[n+1][max(0,dx)]+x
            else:
                dp[n][x]=dp[n+1][15]+x+(N-1-n)*(dx-15)
    L=[0]*N
    for i in range(N):
        L[i]=dp[i][0]
    return L

K=f(A)+[0]
L=[0]+f(A[::-1])[::-1]
ans=10**9
for i in range(N):
    ans=min(ans,i+2*L[i]+2*K[i])
print(ans)

# Optimized solution
from math import ceil,log
N=int(eval(input()))
A=[int(i) for i in input().split()]
def f(A):
    dp=[0]*16
    L=[0]*N
    for i in range(16):
        dp[i]=i
    for n in range(N-2,-1,-1):
        ndp=[0]*16
        nx=ceil(log(A[n]/A[n+1])/log(4)) #A
        for x in range(16):
            dx=nx+x
            if dx <=15:
                #print(max(0,dx))
                ndp[x]=dp[max(0,dx)]+x
            else:
                ndp[x]=dp[15]+x+(N-1-n)*(dx-15)
        dp=ndp
        L[n]=dp[0]
    return L

K=f(A)+[0]
L=[0]+f(A[::-1])[::-1]
ans=10**22
for i in range(N+1):
    ans=min(ans,i+2*L[i]+2*K[i])
print(ans)
# Original solution
INF = 10**10
n = int(eval(input()))
a = list(map(int, input().split()))

dp_fr = [[INF for _ in range(20)] for _ in range(n)]
dp_ba = [[INF for _ in range(20)] for _ in range(n)]

#dp[i][j]: iまで考えてa_iを4^j倍したときの必要最小コスト
for j in range(20):
	dp_fr[0][j] = 2*j

for i in range(1, n):
	k = -30
	while a[i-1] * pow(4, k) < a[i]:
		k += 1
	for j in range(20):
		if j+k < 20:
			dp_fr[i][j] = 2*j + dp_fr[i-1][max(j+k, 0)]

for j in range(20):
	dp_ba[n-1][j] = 2*j

for i in range(n-2, -1, -1):
	k = -30
	while a[i+1] * pow(4, k) < a[i]:
		k += 1
	for j in range(20):
		if j+k < 20:
			dp_ba[i][j] = 2*j + dp_ba[i+1][max(j+k, 0)]

ans = min(dp_ba[0][0], n + dp_fr[n-1][0])
for i in range(n-1):
	ans = min(ans, dp_ba[i+1][0] + i+1 + dp_fr[i][0])

print(ans)

# Optimized solution
INF = 10**10
n = int(eval(input()))
a = list(map(int, input().split()))

dp_fr = [[INF for _ in range(20)] for _ in range(n)]
dp_ba = [[INF for _ in range(20)] for _ in range(n)]

#dp[i][j]: iまで考えてa_iを4^j倍したときの必要最小コスト
for j in range(20):
	dp_fr[0][j] = 2*j

for i in range(1, n):
	if a[i-1] < a[i]:
		k = 0
		while a[i-1] * pow(4, k) < a[i]:
			k += 1
		for j in range(20):
			if j+k < 20:
				dp_fr[i][j] = 2*j + dp_fr[i-1][j+k]
			else:
				dp_fr[i][j] = 2*j + dp_fr[i-1][19] + 2*(i) * (j+k-19)
	else:
		k = 0
		while a[i-1] >= a[i] * pow(4, k+1):
			k += 1
		for j in range(20):
			dp_fr[i][j] = 2*j + dp_fr[i-1][max(j-k, 0)]

for j in range(20):
	dp_ba[n-1][j] = 2*j

for i in range(n-2, -1, -1):
	if a[i+1] < a[i]:
		k = 0
		while a[i+1] * pow(4, k) < a[i]:
			k += 1
		for j in range(20):
			if j+k < 20:
				dp_ba[i][j] = 2*j + dp_ba[i+1][j+k]
			else:
				dp_ba[i][j] = 2*j + dp_ba[i+1][19] + 2*(n-i-1) * (j+k-19)
	else:
		k = 0
		while a[i+1] >= a[i] * pow(4, k+1):
			k += 1
		for j in range(20):
			dp_ba[i][j] = 2*j + dp_ba[i+1][max(j-k, 0)]

#print(*dp_fr, sep="\n")
#print(*dp_ba, sep="\n")

ans = min(dp_ba[0][0], n + dp_fr[n-1][0])
for i in range(n-1):
	ans = min(ans, dp_ba[i+1][0] + i+1 + dp_fr[i][0])

print(ans)
# Original solution
from math import ceil, log2

def max2(x, y): return x if x >= y else y

def getNums(As, N):
    dp = list(range(16))
    nums = [0] * N
    for i in reversed(list(range(N - 1))):
        dx = ceil( log2( As[i] / As[i+1] ) / 2 )
        dp2 = [0] * 16
        for x in range(16):
            nx = x + dx
            if nx <= 15:
                dp2[x] = dp[max2(0, nx)] + x
            else:
                dp2[x] = dp[15] + x + (N - 1 - i) * (nx - 15)
        dp = dp2
        nums[i] = dp[0]
    return nums

N = int(eval(input()))
As = list(map(int, input().split()))

numPstvs = getNums(As, N)
numNgtvs = getNums(As[::-1], N)[::-1]

ans = float('inf')
for i, (p, m) in enumerate(zip(numPstvs + [0], [0] + numNgtvs)):
    ans = min(ans, 2 * p + 2 * m + i)
print(ans)


# Optimized solution
from math import floor, ceil, log2

def getNums(As, N):
    nums = [0] * N
    accNum = 0
    stack = [(N-1, float('inf'))]
    dNow = 0
    for i in reversed(list(range(N - 1))):
        if As[i] <= As[i+1]:
            dd = floor( log2( As[i+1] / As[i] ) / 2 )
            if dd > 0: stack.append((i, dNow))
            dNow -= dd
        else:
            dTgt = dNow + ceil( log2( As[i] / As[i+1] ) / 2 )
            while dNow < dTgt:
                pos, d = stack[-1]
                if dTgt > d:
                    accNum += (d - dNow) * (pos - i)
                    dNow = d
                    stack.pop()
                else:
                    accNum += (dTgt - dNow) * (pos - i)
                    if dTgt == d: stack.pop()
                    dNow = dTgt
                    break
        nums[i] = accNum
    return nums

N = int(eval(input()))
As = list(map(int, input().split()))

numPstvs = getNums(As, N)
numNgtvs = getNums(As[::-1], N)[::-1]

ans = float('inf')
for i, (p, m) in enumerate(zip(numPstvs + [0], [0] + numNgtvs)):
    ans = min(ans, 2 * p + 2 * m + i)
print(ans)
# Original solution
from collections import deque
 
q = deque([]) 

def ct(a,b):
    ans = 0
    while abs(a)<abs(b):
        ans += 2
        a *= 4
    return ans

N = int(eval(input()))
A = [int(a) for a in input().split()]

# A = [3, 1, 4, 1]
# N = len(A)


X = [0] * (N)
Y = [0] * (N)

a = -1
for i in range(N):
    b = a
    if i > 0:
        X[i] = X[i-1]
    else:
        X[i] = 0
    a = A[i]
    t = 0
    if a > 0:
        X[i] += 1
        a *= -2
    
    if i > 0:
        t = 0
        r = b/a
        while r >= 4:
            q.append(i)
            r /= 4
            
        while abs(a)>abs(b):
            if len(q) == 0:
                X[i] += 2 * i
            else:
                X[i] += 2 * (i - q.pop())
            b *= 4
    
q = deque([]) 
a = -1
for i in range(N):
    b = a
    if i > 0:
        Y[i] = Y[i-1]
    else:
        Y[i] = 0
    a = A[N-1-i]
    t = 0
    if a < 0:
        Y[i] += 1
        a *= -2
    
    if i > 0:
        t = 0
        r = b/a
        while r >= 4:
            q.append(i)
            r /= 4
            
        while abs(a)>abs(b):
            if len(q) == 0:
                Y[i] += 2 * i
            else:
                Y[i] += 2 * (i - q.pop())
            b *= 4

mi = min(X[-1], Y[-1])
for i in range(N-1):
    if X[i]+Y[-2-i] < mi:
        mi = X[i]+Y[-2-i]
print(mi)

# Optimized solution
def f(A, s):
    X = [0] * N
    q = []
    a = 0
    for i in range(N):
        b = a
        X[i] = X[i-1]
        a = A[i]
        if a * s < 0:
            X[i] += 1
            a *= -2

        if i == 0:
            continue
            
        r = b/a
        while r >= 4:
            q.append(i)
            r /= 4

        while r < 1:
            X[i] += 2 * (i - (0 if len(q) == 0 else q.pop()))
            r *= 4
            
    return X

N = int(eval(input()))
A = [int(a) for a in input().split()]
X = f(A,-1)
Y = f(A[::-1],1)

mi = min(X[-1], Y[-1])
for i in range(N-1):
    mi = min(mi, X[i] + Y[-2-i])
print(mi)
# Original solution
def partial_match_table(word):
    table = [0] * (len(word) + 1)
    table[0] = -1
    i, j = 0, 1
    while j < len(word):
        matched = word[i] == word[j]
        if not matched and i > 0:
            i = table[i]
        else:
            if matched:
                i += 1
            j += 1
            table[j] = i
    return table

def kmp_search(text, word):
    table = partial_match_table(word)
    i, p = 0, 0
    results = []
    while i < len(text) and p < len(word):
        if text[i] == word[p]:
            i += 1
            p += 1
            if p == len(word):
                p = table[p]
                results.append((i-len(word), i))
        elif p == 0:
            i += 1
        else:
            p = table[p]
    return results

inf = 10**18
s = input().strip()
t = input().strip()
m=(len(t)+len(s)-1+len(s)-1)//len(s)
d = [-1] * (len(s)+1) 
for a, b in kmp_search(m*s, t):
    a, b = a%len(s)+1, b%len(s)+1
    d[a] = b


ls = [0]*(len(s)+1)
vs = set()
for i in range(1, len(s)+1):
    if i in vs:
        continue
    c = 0
    j = i
    while True:
        vs.add(i)
        i = d[i]
        if i == -1:
            break
        c += 1
        if i == j:
            c = inf
            break
        if i in ls:
            c += ls[i]
            break
    if c == inf:
        break
    ls[j] = c
print((max(ls) if c != inf else -1))


# Optimized solution
def partial_match_table(word):
    table = [0] * (len(word) + 1)
    table[0] = -1
    i, j = 0, 1
    while j < len(word):
        matched = word[i] == word[j]
        if not matched and i > 0:
            i = table[i]
        else:
            if matched:
                i += 1
            j += 1
            table[j] = i
    return table

def kmp_search(text, word):
    table = partial_match_table(word)
    i, p = 0, 0
    results = []
    while i < len(text) and p < len(word):
        if text[i] == word[p]:
            i += 1
            p += 1
            if p == len(word):
                p = table[p]
                results.append((i-len(word), i))
        elif p == 0:
            i += 1
        else:
            p = table[p]
    return results

inf = 10**18
s = input().strip()
t = input().strip()
m=(len(t)+len(s)-1+len(s)-1)//len(s)
d = [-1] * (len(s)+1) 
for a, b in kmp_search(m*s, t):
    a, b = a%len(s)+1, b%len(s)+1
    d[a] = b


ls = [-1]*(len(s)+1)
vs = set()
for i in range(1, len(s)+1):
    if i in vs:
        continue
    c = 0
    j = i
    while True:
        vs.add(i)
        i = d[i]
        if i == -1:
            break
        c += 1
        if i == j:
            c = inf
            break
        if ls[i] != -1:
            c += ls[i]
            break
    if c == inf:
        break
    ls[j] = c
print((max(ls) if c != inf else -1))
# Original solution
# Date [ 2020-08-11 10:50:12 ]
# Problem [ test.py ]
# Author Koki_tkg

import sys;      from decimal import Decimal
import math;     from collections import Counter
import bisect;   from itertools import combinations

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 6 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return list(map(int, sys.stdin.readline().strip().split()))
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n = read_int()
    print(((n - 2) * 180))

if __name__ ==  '__main__':
    Main()

# Optimized solution
print(((int(eval(input()))-2)*180))