peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
n = int(input())
a = [int(x) for x in input().split()]

flag = 0
cnt = 1

for i in range(n-1):
    if a[i] < a[i+1] and flag == 0:
        flag = 1
    elif a[i] > a[i+1] and flag == 0:
        flag = 2
    elif flag == 1 and a[i] > a[i+1]:
        cnt += 1
        flag = 0
    elif flag == 1 and a[i] > a[i+1]:
        cnt += 1
        flag = 0

print(cnt)
# Judge status: Accepted
# 英小文字 c が与えられるので、 c が母音であるか判定してください。ここで、英小文字のうち母音は a、e、i、o、uの 5 つです。

c = input()
if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':
    print('vowel')
else:
    print('consonant')
# Judge status: Wrong Answer
K = int(input())
C = input()
C = list(C)
r = C.count("W")
A = C[:r].count("W")
B = C[-K+r:].count("W")
# print(A)
# print(B)
cnt = 0
for _ in range(200000):
    if A > 0:
        if B > 0:
            A -= 1
            B += 1
            cnt += 1
        else:
            A -= 1
            cnt += 1
    else:
        break
print(cnt)
# Judge status: Wrong Answer
K, X = map(int,input().split())

if 500 * K <= X:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
P = list(map(int,input().split()))
minimam = P[0]
answer = 0

for i in range(N):
    if minimam >= P[i]:
        answer += 1
        minimam = P[i]
print(answer)
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

n, a, b = input_nums()

r = n // (a + b)
q = n % (a + b)

ans = r * a
if q >= a:
    ans += a
else:
    ans += q
print(ans)
# Judge status: Wrong Answer
A,B=map(int,input().split())

def judge(a,b):
  if a > b:
    return "Alice"
  elif a == b:
    return "Draw"
  else:
    return "Bob"
  
print(judge(A,B))
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
sumA=sum(A)

if A[0]!=0:
    print(-1)
    exit()

ans=1
p=1
for i in range(1,N):
    p=min(p*2,sumA)
    ans+=p
    p=p-A[i]
    sumA-=A[i]
    if p<=0:
        print(-1)
        exit()


if p<=A[N]<=p*2:
    print(ans+A[N])
else:
    print(-1)
# Judge status: Accepted
# input
C = [list(map(int, input().split())) for i in range(3)]

# check
base = [C[0][0], C[1][1], C[2][2]]
case_AB = [
    1
    for a in range(base[0] + 1)
    for b in range(base[1] + 1)
    for c in range(base[2] + 1)
    if [
        [base[0], b + (base[0] - a), c + (base[0] - a)],
        [a + (base[1] - b), base[1], c + (base[1] - b)],
        [a + (base[2] - c), b + (base[2] - c), base[2]]
    ] == C
]

if case_AB:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b,c=map(int,input().split())
print(max(0,c+b-a))
# Judge status: Wrong Answer
N = int (input())
a=[]
a = list(map(int, input().split()))
count=0

for i in range(0,N):
  if i%2==1 and a[i]%2==1:
    count+=1
print(count)
# Judge status: Wrong Answer
n = int(input())
cnt = 0
t,x,y = 0,0,0
for i in range(n):
  nt, nx, ny  = map(int, input().split())
  if not(abs(nx-x)+abs(ny-y) <= nt-t and t%2 == (x+y)%2):
    print("No")
    exit()
print("Yes")
# Judge status: Accepted
a=input()
b=input()
score=0
for i in range(len(a)):
  if a[i] != b[i]:
    score += 1
    
print(score)
# Judge status: Wrong Answer
n, k = map(int, input().split())
As = list(map(int, input().split()))

if n == k:
    print(1)
    exit()
for i in range(10000):
    # print(i * (k - 1) + k)
    # print((i + 1) * (k - 1) + k)
    if i * (k - 1) + k < n and n <= (i + 1) * (k - 1) + k:
        print(i+2)
# Judge status: Accepted
from sys import stdin, stdout
from time import perf_counter

import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7

# import sys
# sys.stdout = open("e:/python/cp/output.txt","w")
# sys.stdin = open("e:/python/cp/input.txt","r")

s = input()
print(f"A{s[8].upper()}C")
# Judge status: Wrong Answer
c = input()
v = list('abcde')

if c in v:
    print('vowel')
else:
    print('consonant')
# Judge status: Accepted
r = int(input())

p = 6.28318530717958623200

print(r*p)
# Judge status: Accepted
N,Y=(int(x) for x in input().split())
# YY現在の金額
# n:使える枚数
F=0
Y=Y/1000
for i in range(N+1):
    for j in range(N+1-i):
        if (Y-10*i-5*j)==(N-i-j):
            print(i,j,N-i-j)
            F=1
        else:
            continue
    if F==1:break
    

else:
    print("-1 -1 -1")
# Judge status: Accepted

a,b,c,d = map(int,input().split())

if (abs(a-b) <= d and abs(b-c) <= d) or abs(c-a) <= d:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def solve():
    A, B = map(int, input().split())
    if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
        print('Possible')
    else:
        print('Impossible')


if __name__ == "__main__":
    solve()
# Judge status: Accepted


n, m = map(int, input().split())

votes = list(map(int, input().split()))

totalvote = sum(votes)
threshold = totalvote * (1 / (4*m))


votes.sort(reverse=True)


if votes[m-1] < threshold:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
S = input()
if c < d:
  for i in range(a-1, d-1):
    if S[i] == "#" and S[i+1] == "#":
      print("No")
      exit()
  print("Yes")
else:
  for i in range(a-1, d-1):
    if S[i] == "#" and S[i+1] == "#":
      print("No")
      exit()
  for i in range(b-1, min(d, n-1)):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
      print("Yes")
      exit()
  print("No")
# Judge status: Accepted
y, m, d= map(int, input().split('/'))
if int(str(y)+str(m).zfill(2)+str(d).zfill(2)) <= 20190430:
  print('Heisei')
else:
  print('TBD')
# Judge status: Accepted
N, K = map(int, input().split())
A=[0]*N
for i in range(N):
    a=int(input())
    A[i]=a
A=sorted(A)

ans=[]
for i in range(N-K+1):
    ans.append(A[i+K-1]-A[i])

print(min(ans))
# Judge status: Wrong Answer
import math

H = int(input())

count = 1
while True:
    if H == 1:
        break
    H = math.ceil(H/2)
    count += 1

print(2**count-1)
# Judge status: Accepted
n=int(input());print((n-1)*n//2)
# Judge status: Accepted
n,a,b=map(int,input().split())
if a > b or (n==1 and a != b):
  # 該当パターンなし
  print(0)
else:
  print((b-a)*(n-2)+1)
# Judge status: Accepted
N, T = map(int, input().split())
min_c = 1001
for _ in range(N):
    c, t = map(int, input().split())
    if t <= T and c < min_c:
        min_c = c
print('TLE' if min_c == 1001 else min_c)
# Judge status: Accepted
N=input()
print("Yes" if "7" in N else "No")
# Judge status: Accepted
X, Y = map(int, input().split())

number = X
ans = 0

while number <= Y:
    ans += 1
    number *= 2

print(ans)
# Judge status: Accepted
def solve():
    c = input()
    vowel = ['a', 'e', 'i', 'o', 'u']
    if c in vowel:
        print('vowel')
    else:
        print('consonant')


if __name__ == "__main__":
    solve()
# Judge status: Accepted
x,y,z=map(int,input().split())
if abs(y-x) < abs(z-x):
    print("A")
else:
    print("B")
# Judge status: Accepted
one,zero,minus,k = map(int,input().split())
result = 0
if one > k:
    print(k)
else:
    result += one
    k -= one
    if zero > k:
        print(result)
    else:
        k -= zero
        if k > 0:
            result -= k
        print(result)
# Judge status: Wrong Answer
# A - ι⊥l
# https://atcoder.jp/contests/abc058/tasks/abc058_a

a, b, c = map(int, input().split())

result = 'No'

if b - a == c - b:
    result = 'Yes'
elif a - b == b - c:
    result = 'Yes'

print(result)
# Judge status: Wrong Answer
a,b,c=list(map(str,input().split()))
c=b[0]
print('AtCoder '+c+' Contest')
# Judge status: Accepted
n = int(input())
a = list(map(lambda x:int(x),input().split()))
a.sort(reverse=True)
al = 0
bo = 0
if n==1:
  al = a[0]
else:
  for i in range(0,n,2):
    al += a[i]
  for i in range(1,n,2):
    bo += a[i]
print(al-bo)
# Judge status: Accepted
s = input()

for i in range(len(s)):
  if (i+1) % 2 == 0:
    if s[i] == 'R':
      print('No')
      exit()
  else:
    if s[i] == 'L':
      print('No')
      exit()
print('Yes')
# Judge status: Accepted
k, x = map(int, input().split())
if k * 500 >= x:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = list(input())
t = list(input())
s_to_t = {chr(c):set() for c in range(ord('a'),ord('z')+1)}
t_to_s = {chr(c):set() for c in range(ord('a'),ord('z')+1)}

for i in range(len(s)):
    s_to_t[s[i]].add(t[i])
    t_to_s[t[i]].add(s[i])

for c in range(ord('a'), ord('z')+1):
    if len(s_to_t[chr(c)]) > 1 or len(t_to_s[chr(c)]) > 1:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
s=input()
print(s.replace('2017','2018'))
# Judge status: Accepted
import math


def main():
    n, k = input_list()
    a = input_list()
    a = math.ceil((n-k)/(k-1))
    print(1+a)


def input_list():
    return list(map(int, input().split()))


if __name__ == "__main__":
    main()
# Judge status: Accepted
s = input()
t = input()
ans = 'UNRESTORABLE'
for i in range(len(s)-len(t)+1):
    ok = True
    for j in range(len(t)):
        if s[i+j]!='?' and s[i+j]!=t[j]:
            ok = False
    if ok:
        ans = s[:i]+t+s[i+len(t):]
        ans = ans.replace('?','a')
print(ans)
# Judge status: Accepted
n = int(input())
L = [ 0 for _ in range(100) ]
L[0] = 2
L[1] = 1
for i in range(2, 100):
    L[i] = L[i-1] + L[i-2]

print(L[n])
# Judge status: Wrong Answer
N = int(input())
if N == 1:
    print(2)
    exit()
if N == 2:
    print(1)
    exit()
a = 2
b = 1
for i in range(2,N):
    a,b = b,a+b
print(b)
# Judge status: Accepted
a,b,c,d=map(int,input().split())
ans=0
if not a<d:
  print(d)
else:
  if not a+b<d:
    print(a)
  else:
    print(2*a+b-d)
# Judge status: Accepted
# coding: utf-8
# Your code here!

N = int(input())

flag = 0
for i in range(1, 10, 1) : 
    for j in range(1, 10, 1) : 
        if N == i*j : 
            flag = 1
            
if flag == 1 : 
    print("Yes")
else : 
    print("No")
# Judge status: Accepted
r,g,b=input().split()
print("YES" if int(r+g+b)%4==0 else "NO")
# Judge status: Accepted
s = input()
n = len(s)

for i in range(1,n):
    ss = s[:-i]
    if len(ss)% 2 ==0:
        if ss[:(n-i)//2] == ss[(n-i)//2:]:
            print(len(ss))
            exit()
# Judge status: Wrong Answer
def main():
    N, M =map(int, input().split())

    left = 1
    right = N
    for _ in range(M):
        print(left, right)
        left += 1
        right -= 1


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())

if(n%10 == 9 or n//10 == 9):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,l=map(int,input().split())
s=[]
for _ in range(n):
    s1=input()
    s.append(s1)
s=sorted(s)
ss=''
for i in s:
    ss+=i
print(ss)
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))
ans=0
while True:
  for i in range(n):
    if A[i]%2==0:
      A[i]//=2
    else:
      print(ans)
      exit()
  ans+=1
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))
m = 10**10
for p in range(1, max(l)+1):
    tmp = 0
    for x in l:
        tmp += (x-p)**2
    m = min(m, tmp)

print(m)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

cnt1 = sum(i % 4 == 2 for i in a)
cnt2 = sum(i % 4 == 0 for i in a)
print('Yes 'if n <= 2 * cnt2 + max(1, cnt1) else 'No')
# Judge status: Accepted
S=input()
N=len(S)+1

A=[0]*N
B=[0]*N

for k in range(N-1):
    if S[k]=="<":
        A[k+1]=A[k]+1

for k in range((N-1)-1,-1,-1):
    if S[k]==">":
        B[k]=B[k+1]+1
        
print(sum(map(lambda x:max(A[x],B[x]),range(N))))
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
x = int(input())
res = 0

for ai in range(a):
  for bi in range(b):
    for ci in range(c):
      total = 500 * ai + 100 * bi + 50 * ci
      if x == total:
        res += 1
        
print(res)
# Judge status: Accepted
li = [int(input()) for _ in range(5)]
def fun(a):
    if a % 10 == 0:
        return a
    else:
        return a + 10 - a % 10
su = sum(list(map(fun, li)))
last = li[0]
for l in li:
    if l % 10 != 0 and last % 10 > l % 10:
        last = l
print(su - fun(last) + last)
# Judge status: Accepted
c=sum(a:=[*map(int,[*open(0)][1].split())])
b=1
print(max(-1,sum((b:=min(c:=c-a,b-a<<1))for a in a)+1))
# Judge status: Accepted
N = int(input())
B = input().split()
B = [int(x) for x in B]

s = B[0]
for i in range(N-2):
  s += min(B[i],B[i+1])
s += B[N-2]

print(s)
# Judge status: Accepted
a, b, c = map(lambda x: int(x), input().split())
lis = [a, b, c]
lis.sort()

if lis[0] + lis[1] == lis[2]:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
def main():
    n, m = map(int, input().split())
    Xs = sorted(list(map(int, input().split())))
    Xs_diff = []
    for i in range(1, m):
        Xs_diff.append(Xs[i]-Xs[i-1])

    Xs_diff.sort()
    ans = sum(Xs_diff[:(n+1)])
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import re

s = input()
res = re.search('A[A-Z]+Z', s)
print(res.end() - res.start())
# Judge status: Wrong Answer
N = int(input())
A = input().split(' ')
A = [int(A[i]) for i in range(N)]
count = 0
while count<10:
  for i in range(N):
    if A[i]%2 == 0:
      A[i] /= 2
    else:
      break
  else:
    count += 1
    continue
  break

print(count)
# Judge status: Wrong Answer
s=input()
ok=True
for i in s:
    if i.count(s)%2!=0:
        ok=False
if ok:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
# -*- coding: utf-8 -*-

a,b = [int(i) for i in input().rstrip().split()]


print( (a-1)+1 if b>=a else (a-1) )
# Judge status: Accepted
inpl = lambda: list(map(int,input().split()))
A, B = inpl()
print(A*B)
# Judge status: Wrong Answer
A = [list(map(int, input().split())) for i in range(3)]
n = int(input())

b = []

for i in range(n):
  b.append(int(input()))


for i in range(len(b)):
  for a_i in range(len(A[0])):
    for a_j in range(len(A[1])):
      if A[a_i][a_j] == b[i]:
        A[a_i][a_j] = 0


for i in range(len(A[0])):
  if A[0][i] != 0 and A[i][0] != 0 and A[i][i] != 0:
    print("No")
    break

  if i == 2:
    print("Yes")
# Judge status: Accepted
import numpy as np

N, Q = map(int, input().split())
S = np.zeros(N+1, dtype="S1")
S[1:] = list(input())

A = (S == b'A')
C = (S == b'C')
AC = (A[:-1] & C[1:]) # Aが右、Cが左になる形
AC_cum = list(AC.cumsum())

for _ in range(Q):
  l, r = map(int, input().split())
  print(AC_cum[r-1] - AC_cum[l-1])
# Judge status: Accepted
s=str(input())
print("".join(["x" for i in range(len(s))]))
# Judge status: Accepted
N,M=map(int,input().split())
X=[0]*(N+1)
X[1]=1
Y=[1]*(N+1)
a,b=0,0
for i in range(M):
  a,b=map(int,input().split())
  X[b]|=X[a]
  Y[b]+=1
  Y[a]-=1
  if Y[a]==0:
    X[a]=0
print(sum(X))
# Judge status: Wrong Answer
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

k,a,b = readInts()

if a+2<b:
	ans = (k+1)//(a+2)*b + (k+1)%(a+2)
else:
	ans = k+1

print(ans)
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split()))

num = P[0]
ans = 1

for i in range(1, N):
    if num > P[i]:
        num = P[i]
        ans += 1

print(ans)
# Judge status: Accepted
S = input()
N = len(S) # タイルの数

a = sum((1 << i) for i in range(0, N, 2)) # 0b ...0101
a_flip = bin(a ^ int(S, base = 2))[2:].count('1')

print(min(a_flip, N - a_flip))
# Judge status: Accepted
a=int(input())
s=input()
if a >= 3200 :
  print(s)
else :
  print('red')
# Judge status: Accepted
N = int(input())
print(((N + 1) // 2) / N)
# Judge status: Accepted
import math
def main():
  n=int(input())
  s = [input() for i in range(n)]
  m=int(input())
  t = [input() for i in range(m)]
  ans=0
  while len(s)>0:
    num=s.count(s[0])-t.count(s[0])
    if ans<num:
      ans=num
    s=[x for x in s if x != s[0]]
  print(ans)
  
main()
# Judge status: Wrong Answer
H = int(input())
SUM = 0
cn = 1

for i in range(10000):
    H = H // 2
    cn = cn + 1
    if H == 1:
        break

for i in range(cn):
    SUM = SUM + (2**i)
    
print(SUM)
# Judge status: Accepted
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

hand = {'r':p, 's':r, 'p':s}
win = {'r':'p', 's':'r', 'p':'s'}

ans = 0
u = []
for i,tt in enumerate(t):
    if i >= k and tt == t[i-k] and u[i-k] == win[tt]:
            u.append(tt)
    else:
        u.append(win[tt])
        ans += hand[tt]
print(ans)
# Judge status: Accepted
N, A, B = map(int, input().split())
x = N // (A + B)
y = N % (A + B)
if y < A:
    print(x*A + y)
else:
    print(x*A + A)
# Judge status: Wrong Answer
N, Y = map(int, input().split())
 
for x in range(N+1):
  for y in range(N+1-x):
        if x*10000 + y*5000 + (N+1-x-y)*1000 == Y:
           print(x, y, N+1-x-y)
           exit()

print(-1,-1,-1)
# Judge status: Accepted
n = int(input())
s = input()
t = input()

ans = 2*n

for i in range(1,n+1):
    if s[-i:] == t[:i]:
        ans = 2*n - i
print(ans)
# Judge status: Accepted
N,K=map(int, input().split())

t = 0
import math
for x in range(1, min(N,K-1)+1):
    t += (1-pow(0.5, math.ceil(math.log2(K/x))))

print(1 - t / N)
# Judge status: Accepted
from collections import Counter as C

_ = input()
a = C([int(x) for x in input().split()])

b = []
for k, v in a.items():
    if 4 <= v:
        b.append(k)
    if 2 <= v:
        b.append(k)
else:
    if len(b) <= 1:
        print(0)
    else:
        b.sort()
        print(b[-1] * b[-2])
# Judge status: Accepted
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n = int(rl())
	ans = 1
	lim = 10**18
	flag = False
	for a in rli():
		if flag:
			if a == 0:
				ans = 0
				print(0)
				return
			continue
		ans *= a
		if ans > lim:
			flag = True
	print(ans if not flag else -1)
	stdout.close()

if __name__ == "__main__":
	main()
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

x=INT()

for i in range(-500,501):
    for j in range(-500,501):
        if i**5-j**5==x:
            print(i,j)
            exit()
# Judge status: Wrong Answer
x = input()
if x == 0:
  print('1')
elif x == 1:
  print('0')
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
print("Yes" if (abs(a-b)<=d and (abs(b-c)<=d)) else "No")
# Judge status: Accepted

def main():
    N, D = map(int, input().split())
    count = 0
    for n in range(N):
        X, Y = map(int, input().split())

        if X**2 + Y**2 <= D**2:
            count += 1
    
    print(count)


if __name__ == '__main__':
    main()
# Judge status: Accepted
x = int(input())
import math
f = 1
for A in range(-10**5,10**5):
    A5 = A ** 5
    if x - A5 > 0:
        f = -1
        B = round(math.pow(x - A5,1/5),0)
    else:
        B = round(math.pow(-(x - A5),1/5),0)
    if  A5 == x + int(B*f) ** 5:
        print(A,int(B)*f)
        quit()
# Judge status: Wrong Answer
X, Y = map(int, input().split())

for i in range(1, X+1):
    for j in range(1, X+1):
        if Y == i * 2 + j * 4:
            print('Yes')
            exit()

if Y == X * 2 or Y == X * 4:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def main():
    n, m = list(map(int, input().split()))
    if m <= 2 * n:
        print(m // 2)
    else:
        m -= 2 * n
        print(n + m // 4)

if __name__ == '__main__':
    main()
# Judge status: Accepted
X = int(input())

def binary_search(b):
    l, r = -10 ** 9, 10 ** 9
    while r-l > 1:
        m = (l+r)//2
        x = m**5 - b**5
        if x < X:
            l = m
        else:
            r = m
    return r

for b in range(-10000, 10000):
    a = binary_search(b)
    if a ** 5 - b ** 5 == X:
        print(a, b)
        break
# Judge status: Wrong Answer
# list に入力を格納
list = list(map(int, input().split()))
# 小さい順に並び替え
list.sort()

if list[0] == 5 and list[1] == 5 and list[2] == 7:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n = input().split()
print(n)

if int(n[0]) >= 10:
  print(n[1])
else:
  print(100 * (10 - int(n[0])) + int(n[1]))
# Judge status: Wrong Answer
import sys
def LI(): return list(map(int, sys.stdin.readline().split()))
a = LI()
i = 0.1
elist,blist= [],[]
for b in range(9):
  elist.append(int((a[0]+1-i)/0.08))
  blist.append(int((a[1]+1-i)/0.1))
  i += 0.1
elist.append(int(a[0]/0.08))
blist.append(int(a[1]/0.1))
blist.sort()
for b in blist:
  if b in elist:
    print(b)
    sys.exit()
print(-1)
# Judge status: Accepted
n=int(input())
num_i=0
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        num_i=i
num_j=n//num_i
print((num_i+num_j-2))
# Judge status: Accepted
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, M = rl()
A = rl()

import heapq

heap = []
for i, a in enumerate(A):
	heapq.heappush(heap, (-a, i))
nums = [0] * N
for i in range(M):
	a, i = heapq.heappop(heap)
	if abs(a) < 1:
		break
	a = a / 2
	nums[i] += 1
	heapq.heappush(heap, (a, i))
ans = 0
for i in range(N):
	ans += A[i] // pow(2, nums[i])
print(ans)
# Judge status: Accepted
N = int(input())
ans = 0

for x in range(1, N+1):
    if len(str(x)) % 2 == 1:
        ans += 1

print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
q=int(input())
dic = {}
ans = 0
for  x in a:
    if  x not in dic:
        dic[x] = 1
    else:
        dic[x]+=1
    ans += x

for _ in range(q):
    b,c=map(int,input().split())
    if b not in dic:continue
    ans += (c-b)*dic[b]
    if c not in dic:
        dic[c] = dic[b]
    else:
        dic[c]+=dic[b]
    dic[b]=0
    print(ans)
# Judge status: Accepted
def main():
    n = int(input())
    b = list(map(int, input().split()))
    a = [b[0]] + b
    for i in range(n - 1):
        if max(a[i], a[i + 1]) != b[i]:
            a[i] = min(a[i], b[i])
            a[i + 1] = min(a[i + 1], b[i])
    print(sum(a))


if __name__ == '__main__':
    main()
# Judge status: Accepted
n, k = map(int,input().split())
H = list(map(int,input().split()))

H.sort(reverse=True)

del H[0:k]
print(sum(H))
# Judge status: Accepted
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

sum = 0
pre = -1

for A in A_list:
    sum += B_list[A - 1]

    if pre + 1 == A:
        sum += C_list[A - 2]

    pre = A

print(sum)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
r = 1
maxi = [0] * (n + 1)

ok = True

for i in range(n + 1):
    if r <= 0 or a[i] > r:
        ok = False
        break
    maxi[i] = r
    r = 2 * (r - a[i])

branches = a[n]
ans = a[n]
for i in range(n - 1, -1, -1):
    branches = min(branches + a[i], maxi[i])
    ans += branches

if not ok:
    ans = -1

print(ans)
# Judge status: Accepted
n=int(input())
ans=""
while n>0:
    
    c=chr((n-1)%26 + 97)
    ans = c+ans
    n = (n-1)//26
    
print(ans)
# Judge status: Accepted
s = input()
k = int(input())
count = 0
for i in range(len(s)):
    if s[i] != "1":
        count = i
        break
if k<count+1:
    print("1")
else:
    print(s[count])
# Judge status: Wrong Answer
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    print(360//int(input()))

if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
N=int(input())+1
sum=0
for i in range(1,N):
  for j in range(1,N):
    tmp=math.gcd(i,j)
    for k in range(1,N):
      sum+=math.gcd(tmp,k)
print(sum)
# Judge status: Accepted
from collections import defaultdict
N, K = map(int, input().split())
d = defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split())
    d[a] += b
d = list(d.items())
d = sorted(d, key=lambda x: x[0])
cnt = 0
for v, count in d:
    cnt += count
    if cnt >= K:
        print(v)
        exit()
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

cnt = [0] * 317
res = 0
for v in a:
    if v <= 316:
        cnt[v] += 1
    else:
        res += 1

for i in range(1, 317):
    if cnt[i] < i:
        res += cnt[i]
    elif cnt[i] > i:
        res += cnt[i] - i

print(res)