peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
from sys import stdin
def main():
    N=int(stdin.readline().strip())
    A=[int(x) for x in stdin.readline().split()]
    j=0
    ans=0
    for i in range(1,len(A)):
        if A[j]>=A[i]:
            j+=1
        else:
            break
        ans=i+1
    print(min(ans+1,N))
main()
# Judge status: Accepted
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
p = sorted(p)
ans = 0
for i in range(K):
    ans += p[i]
print(ans)
# Judge status: Accepted
L,R,d = map(int,input().split())
ans = 0

for n in range(L,1+R):
  if n%d==0:
    ans+=1

print(ans)
# Judge status: Wrong Answer
a = int(input())
lst_l = [6, 9]
counter = 0
while a!=0:
  lst = [0, 0]
  for j in range(2):
    for i in range(0, 20):
      if a < lst_l[j]**i:
        break
      lst[j] = lst_l[j]**i
  a -= max(lst)
  counter += 1
print(counter)
# Judge status: Accepted
w, h, n = map(int, input().split())

left = 0
right = w
high = h
low = 0
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        left = max(left, x)
    if a == 2:
        right = min(right, x)
    if a == 3:
        low = max(low, y)
    if a == 4:
        high = min(high, y)

print(max(0, right - left) * max(0, high - low))
# Judge status: Wrong Answer
s=input()
n=len(s)
if len(set(s))==1:
    print(0)
else:
    print(min(n,n-s.count('1'))*2)
# Judge status: Accepted
S = list(input())
S.sort()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N,A,B = map(int,input().split())

dif = abs(A-B)
if(dif%2 == 0):
  ans = dif//2
else:
  #A1_diff = A-1
  B1_diff = B-1
  AN_diff = N-A
  #BN_diff = N-B
  ans = min(B1_diff, AN_diff)
print(ans)
# Judge status: Wrong Answer
N,M = map(int,input().split())

goto_N = [0]*N
from_1 = [0]*N

for _ in range(M):
    a,b = map(int,input().split())
    if a == 1:
        from_1[b] = 1
    elif b == N:
        goto_N[a] = 1

for i in range(N):
    if goto_N[i] and from_1[i]:
        print("POSSIBLE")
        exit()

print("INPOSSIBLE")
# Judge status: Accepted
def main():
    x = int(input())
    print(x ^ 1)


if __name__ == '__main__':
    main()
# Judge status: Accepted
A, B = map(int, input().split())
ans = 'Impossible'
if A % 3 == 0:
  ans = 'Possible'
elif B % 3 == 0:
  ans = 'Possible'
elif (A+B) % 3 == 0:
  ans = 'Possible'
print(ans)
# Judge status: Accepted
num = list(input())

output = 0 

for i in num:
    if i =='1':
        output += 1
    
print(output)
# Judge status: Accepted
# E - Crested Ibis vs Monster
H, N = map(int, input().split())
AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append([a,b])
AB.sort()

DP = [float('inf') for i in range(2*10**4 + 1)]
DP[0] = 0
for i in range(H):
    for ab in AB:
        DP[i+ab[0]] = min(DP[i+ab[0]], DP[i] + ab[1])

print(min(DP[H:]))
# Judge status: Wrong Answer

def main():
    n = int(input())
    a = list(map(int, input().split(' ')))
    buka = [0]*n
    print(a)

    for i in a:
        buka[i-1] += 1

    for i in buka:
        print(i)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
s=input()
a=s[:len(s)//2]
b=s[(len(s)//2)+1:]
if a==reversed(a) and b==reversed(b):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
A = iil()

odd = 0
even = 0
mulof4 = 0
for i in A:
    if i%2 == 1:
        odd += 1
    elif i%4 == 2:
        even += 1
    else:
        mulof4 += 1

if odd > mulof4+1:
    print('No')
else:
    if odd < mulof4+1:
        print('Yes')
    else:
        print("Yes" if even == 0 else 'No')
# Judge status: Wrong Answer
from collections import deque
import sys
input = sys.stdin.readline
N = int(input())
A = deque()
B = deque()
time = 0
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    time += 0
    if time > B[i]:
        print("No")
        sys.exit()

print("Yes")
# Judge status: Wrong Answer
N,D = map(int, input().split())
print(N//(2*D+1)+1)
# Judge status: Accepted
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    if N <= 999:
        print('ABC')
    else:
        print('ABD')

if __name__ == '__main__':
    resolve()
# Judge status: Accepted
s=input()
x=0
y=0
j=0
for i in range(len(s)):
  if j==0 and s[i]=="A":
    j+=1
    x=i
  elif j==1 and s[i]=="Z":
    y=i
print(y-x+1)
# Judge status: Wrong Answer
x = list(map(int,input().split()))

for i in range(5):
    if i == 0:
        print(i)
# Judge status: Accepted
t = input()
print(t.replace('?','D'))
# Judge status: Accepted
n, k = map(int, input().split())
lis = list(map(int, input().split()))

su = [0] * (n + 1)

for i in range(n):
    su[i + 1] = su[i] + ((lis[i] + 1) / 2)

res = 0
for j in range(n - k + 1):
    res = max(res, su[j + k] - su[j])
    
print('{:.12f}'.format(res))
# Judge status: Accepted
n = input()

if '9' in n:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
X, A, B = map(int, input().split())
mypoint = 0
if mypoint-A+B<=mypoint:
    print("delicious")
elif mypoint-A+B<=X:
    print("safe")
else:
    print("dangerous")
# Judge status: Accepted
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n ,m = I2()
    if n == 2 or m == 2:
        print(0)
    else:
        print(max(1, n - 2)*max(1, m - 2))
# Judge status: Accepted
N, x = map(int, input().split())
an = list(map(int, input().split()))
an.sort()
ans = 0
for a in an:
    x -= a
    if x < 0:
        break
    ans += 1
if x > 0:
    ans -= 1
print(ans)
# Judge status: Accepted
a = input()
c = 0
for i in range(len(a) // 2):
    if a[i] != a[- 1 - i]:
        c += 1
print(c)
# Judge status: Accepted
s = input()
if s == 'Sunny': print('Cloudy')
elif s == 'Cloudy': print('Rainy')
else: print('Sunny')
# Judge status: Wrong Answer
n = int(input())
AB = [list(map(int,input().split())) for _ in range(n)]
AB.sort(key=lambda x: x[1], reverse=True)
# print(AB)
free = 0
now = 0
ok = True
for necessary, deadline in AB:
    if necessary <= free:
        free -= necessary
        continue
    if now + necessary > deadline:
        ok = False
        break
    free = deadline - necessary - now
    now = deadline

print("Yes" if ok else "No")
# Judge status: Wrong Answer
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H.sort()
df = 0
min_h = H[K-1]-H[0]

for i in range(1, N-K-1):
    new_h = H[i+K-1]-H[i]
    if new_h < min_h:
        min_h = new_h

print(min_h)
# Judge status: Wrong Answer
import math

X = int(input())
ans = 0
money = 100 #初期金額

while money < X:
    money += math.floor(money*0.01)
    ans += 1
    
print(ans)
# Judge status: Accepted
N = int(input())
a_list = list(map(int, input().split()))

cnt = 0
for i, a in enumerate(a_list, 1):
    if i%2==1 and a%2==1:
        cnt += 1
print(cnt)
# Judge status: Accepted
n, m = map(int, input().split())
ans = [0]*n

for i in range(m):
    a, b = map(int, input().split())
    ans[a-1] += 1
    ans[b-1] += 1

for i in range(n):
    print(ans[i])
# Judge status: Accepted
print('Yes' if input() == input()[:-1] else 'No')
# Judge status: Accepted
N = int(input())
C = input()

num_R = C.count("R")
num_W = C.count("W")

C_fin = ["R" if i < num_R else "W" for i in range(len(C))]

count = 0
for c, c_fin in zip(C, C_fin):
    if(c == c_fin):
        count += 1

ans = (len(C) - count)//2

print(ans)
# Judge status: Wrong Answer
A_int_list = list(map(int, input().split()))

if sum(A_int_list) <= 22:
    print('bust')
else:
    print('win')
# Judge status: Accepted
s = str(input())
s1 = [s[i] for i in range(4)]
from collections import Counter
s2 = Counter(s1).most_common(2)
if s2[0][1] == 2 and s2[1][1] == 2:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a, b = map(int, input().split())
if a == 1:
    a = 14
if b == 1:
    b = 14
if a == b:
    print("Draw")
else:
    print("Alice") if a > b else print("Bob")
# Judge status: Wrong Answer
t=list(input())
s=list(input())
if reversed(t)==s and reversed(s)==t:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
n = int(input())

i = 0
while(True):
  if 2**i > n:
    print(2**(i-1))
    break
  else :
    i += 1
# Judge status: Accepted
# import math
# import bisect
# import heapq
# from collections import deque
# import numpy as np

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

ans = r
if n < 10:
    ans = r + 100 * (10 - n)
print(ans)
# Judge status: Accepted
A = int(input())
ans = 0
listA = []
for i in range(A):
    listA.append(list(map(int,input().split())))
listA = listA[::-1]
for i in range(A):
    if (listA[i][0]+ans) % listA[i][1] == 0:
        continue
    if listA[i][1] == 1:
        continue
    ans += listA[i][1]-(listA[i][0]+ans)%listA[i][1]
print(ans)
# Judge status: Accepted
def main():
    N, L = map(int, input().split())

    e = sorted((x + L for x in range(N)), key=lambda x: abs(x))
    ans = N * L + (N - 1) * N // 2 - e[0]
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
B=[]
C=0
for i in range(N):
    if A[i]%2==0:
        B.append(A[i])
for i in range(len(B)):
    if B[i]%3!=0 and B[i]%5!=0:
        C+=1
if C==0:
    print('APPRPVED')
if C!=0:
    print('DENIED')
# Judge status: Accepted
[L, R, d] = list(map(int, input().split()))
max_d = R // d
min_d = L // d
sho_R = R % d
sho_L = L % d
if sho_R == 0 and sho_L == 0:
  ans = max_d - min_d + 1
else:
  ans = max_d - min_d
print(ans)
# Judge status: Accepted
H, N = map(int, input().split())
a = list(map(int, input().split()))

if sum(a) >= H:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
m=max(l)
print('Yes' if sum(l)-m>m else 'No')
# Judge status: Wrong Answer
import math
x,y = map(int,input().rstrip().split(' '))
n = int(math.log2(y/x))
print(n)
# Judge status: Accepted
# A - Digits Sum

N = input()
N_int = int(N)
mylist = ['10','100','1000','10000','100000']
ans = 0

if N in mylist:
    ans = 10
else:
    for i in range(len(N)):
        ans += (N_int % 10)
        N_int = N_int // 10

print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())

if n % 2 == 1:
    for i in range(m):
        print(1+i, n-1-i)
else:
    for i in range(m):
        print(1+i, n-i)
# Judge status: Wrong Answer
nu = int(input())

lis = []
ans = 0

for i in range(nu):
    t = int(input())
    lis.append(t)

lis.sort()

for i in range(10*18):
    tes = lis[-1] * (i+1)
    for f in lis:
        if tes % f == 0:
            ans = 1
        else:
            ans = -1
            break
    if ans == 1:
        break

print(tes)
# Judge status: Wrong Answer
N = int(input())
B = list(map(int, input().split()))
B.append(10 ** 5 + 1)
ans = 0
for i in range(N - 1):
  ans += min(B[i], B[i + 1])
  
print(ans)
# Judge status: Accepted
A,B = map(int,input().split())
S = input()
for i in range(A+B+1):
    if i < A and S[i] == '-':
        print('No')
        exit(0)
    elif i == A and S[i] != '-':
        print('No')
        exit(0)
    elif i > A and S[i] == '-':
        print('No')
        exit(0)
print('Yes')
# Judge status: Accepted
n, k = map(int, input().split())

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

if k == 1:
    min_num = 10**20
    for i in x:
        if abs(i) < min_num:
            min_num = abs(i)
    print(min_num)
    exit()

min_dist = 10**20

dist = 0

for i in range(n-k+1):
    dist = (x[i+k-1] - x[i])
    dist += min(abs(x[i+k-1]), abs(x[i]))
    if dist < min_dist:
        min_dist = dist

print(min_dist)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

A.sort()
A.reverse()

happy =  0
circle = [A[0], A[1]]
for i in range(2, N):
    circle.insert(len(circle)-2, A[i])
    happy += min(circle[-1], circle[-3])

print(happy)
# Judge status: Wrong Answer
s = input()
print('YES') if s[2] == s[3] and s[4] == s[5] else print('NO')
# Judge status: Wrong Answer
n,k = map(int, input().split())
A = list(map(int, input().split()))

m = min(A)
i = A.index(m)
cnt = 0
if i!=0:
    cnt += -(-(i-1)//(k-1))
if i!=n-1:
    cnt += -(-n+i)//(k-1)

print(cnt)
# Judge status: Wrong Answer
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()
if k>e -a:
    print "yay"
else:
    print":("
# Judge status: Accepted
from decimal import Decimal

def main():
    A, B = input().split()
    A = Decimal(A)
    B = Decimal(B)
    print(int(A * B))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a = int(input())
print("Yes" if a % 9 == 0 and a != 0 else "No")
# Judge status: Accepted
def main():
    n,a = (int(input()) for _ in range(2))
    print('Yes' if n%500 <= a else 'No')

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
x_ = list(map(int, input().split()))
 
for i in range(len(x_)):
  if x_[i] == 0:
    print(i)
# Judge status: Wrong Answer
def main():
    n,m,X,Y=sorted(map(int,input().split()))
    x=max([X]+list(map(int,input().split())))
    y=min([Y]+list(map(int,input().split())))
    print("No War" if x<y else "War")
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())

k = 1
i = 1
while k < n:
    i += 1
    k += i

while n > i:
    print(i)
    n -= i
    i -= 1
print(n)
# Judge status: Wrong Answer
K = int(input())
S = input()
Sl = len(S)
if Sl <= K:
  ans = S
else:
  newS = S[0 : K-1]
  ans = (newS + "...")
print(ans)
# Judge status: Accepted
mod = 10**9+7

f = [1]
for i in range(1, 2001):
    f.append(f[-1]*i%mod)

S = int(input())
ans = 0
for n in range(1, S//3+1):
    r = S-n*3
    ans += f[r+n-1] * pow(f[n-1], mod-2, mod) * pow(f[r], mod-2, mod) % mod # comb(r+n-1, r)                                                                                        
    ans %= mod
print(ans)
# Judge status: Accepted
S=input()
N=[[0,0] for i in range(len(S)+1)]

for i in range(len(S)):
    if(S[i]=="<"):
        N[i+1][0]=N[i][0]+1
    
    if(S[-1-i]==">"):
        N[-2-i][1]=N[-1-i][1]+1
s=0
for i in range(len(N)):
    s+=max(N[i][0],N[i][1])
print(s)
# Judge status: Accepted
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))

for i in range(1, n+1):
    a[i] += a[i-1]
for i in range(1, m+1):
    b[i] += b[i - 1]

ans = 0
b_cnt = m
for a_cnt in range(n+1):
    if a[a_cnt] > k:
        continue
    while a[a_cnt] + b[b_cnt] > k:
        b_cnt -= 1
    ans = max(ans, a_cnt + b_cnt)
print(ans)
# Judge status: Accepted
# coding: utf-8
n, x = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)
for i in range(n-1):
    s = A[i+1] + A[i]
    if s > x:
        if s-x > A[i+1]:#後ろから全部引ける時
            t = s-x-A[i+1]
            A[i+1] = 0
            A[i] -= t
        else:#後ろから全部引くと負になるとき(前からも引く)
            A[i+1] -= s - x
print(S - sum(A))
# Judge status: Wrong Answer
S=input()

prv=''
cnt=1
for i in range(len(S)):
    #print(i,S[i],cnt,prv)
    if S[i] == prv:
        continue
    cnt+=1
    prv=S[i]
    
print(cnt)
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lst = [a,b,c,d,e]
last = 9
ttl = 0
for i in range(5):
    if lst[i]%10 != 0:
        ttl += (lst[i]+(10-lst[i]%10))
    if lst[i]%10 == 0:
        ttl += lst[i]
    if 0 <(lst[i]%10) <= last:
        last = lst[i]%10
print(ttl-(10-last))
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = ((N - 1) + (K - 1 - 1)) // (K - 1)
print(ans)
# Judge status: Wrong Answer
def main():
    n, x = map(int, input().split())
    A = list(map(int, input().split()))

    A_sorted = sorted(A)

    res = 0

    for kids in A_sorted:
        if x - kids >= 0:
            x = x - kids
            res += 1
    
    print(res)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())

if N == 7 or N == 5 or N ==3:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
L = int(input())

temp = 0
for i in range(1,L):
    for j in range(1,L-i):
        mult = i*j*(L-i-j)
        if(temp < mult):
            temp = mult
print(float(temp))
# Judge status: Wrong Answer
# https://atcoder.jp/contests/abc176/tasks/abc176_b
n = int(input())
if n % 9 == 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
n, k = map(int, input().split())
s = input()
r = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        r += 1
print(min(r + 2 * k, n - 1))
# Judge status: Wrong Answer
A, B = map(int, input().split())
ans = 0
for i in range(A, B + 1):
    sita = i % 100
    ue = i // 1000
    if sita == ue:
        ans += 1
print(ans)
# Judge status: Wrong Answer
A, B = input().split()

a01 = int(A[0:2])
a43 = int(''.join(list(reversed(A[3:5]))))
if a01 < a43:
  amin = int(A[1:3]) + 1
else:
  amin = int(A[1:3])

b01 = int(B[0:2])
b43 = int(''.join(list(reversed(B[3:5]))))
if b01 <= b43:
  bmin = 100 - int(B[1:3]) - 1
else:
  bmin = 100 - int(B[1:3])

n0 = int(B[0]) - int(A[0]) + 1

print(n0 * 100 - amin - bmin)
# Judge status: Wrong Answer
import math

h = int(input())
w = int(input())
n = int(input())

print(math.ceil(n)//max(h, w))
# Judge status: Accepted
from math import factorial
import sys
sys.setrecursionlimit(2000000)
# import math
# import itertools
# import statistics
# import numpy as np
# import collections
#n = int(input())
n, m = list(map(int, input().split()))
if abs(n-m) >= 2:
    print(0)
else:
    if n == m:
        a = factorial(n) * factorial(m) * 2
    else:
        a = factorial(n) * factorial(m)
    print(a % (pow(10, 9)+7))
# Judge status: Accepted
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
roads = []
for i in range(m):
    roads += [list(map(int, input().split()))]
for road in roads:
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(1))
# Judge status: Accepted
A, B, C = map(int, input().split())

i = 0
Ap = A
Bp = B
Cp = C
while A%2 == 0 and B%2 == 0 and C%2 == 0:
  A = Bp//2 + Cp//2 
  B = Ap//2 + Cp//2 
  C = Bp//2 + Ap//2 
  i += 1
  Ap = A
  Bp = B
  Cp = C
  if A == B == C:
    i = -1
    break


print(i)
# Judge status: Accepted
s = input()

a = int(s[:2])
b = int(s[2:])

if 0 <  a <= 12 and 0 < b <= 12:
  print("AMBIGUOUS")
elif (a > 12 or a == 0) and 0 < b <= 12:
  print("YYMM")
elif 0 < a <= 12 and (b > 12 or b == 0):
  print("MMYY")
else:
  print("NA")
# Judge status: Wrong Answer
a=int(input())
b=int(input())
c=int(input())
d=int(input())
count=0
for i in range(a+1):
    for j in range(b+1):
        for z in range(c+1):
            if a*500+b*100+c*50 == d:
                count+=1
print(count)
# Judge status: Accepted
k=int(input())
a,b=map(int,input().split())

if a % k == 0:
    print("OK")
elif (a + k - (a % k)) <= b:
    print("OK")
else:
    print("NG")
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print('Yey!')
else:
    print(':(')
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))

A = sorted(A, reverse=True)
B = set(A)

ans = 0
keep = 0

for i in B:
    if A.count(i) >= 4:
        ans = max(keep * i, i**2)
    elif A.count(i) >= 2:
        ans = keep * i
        keep = i
print(ans)
# Judge status: Accepted
n = int(input())
list_s = list(input())
for i in range(0, len(list_s)):
    tmp = ord(list_s[i]) + n
    if tmp > ord("Z"):
        tmp -= 26
    list_s[i] = chr(tmp)
print("".join(list_s))
# Judge status: Accepted
S = input()
T = input()

N = len(S)
count = 0

for i in range(N):
  if S[i] != T[i]:
    count += 1

print(count)
# Judge status: Wrong Answer
from copy import *
n,m=map(int,input().split())
t=deepcopy(n)
while True:
    if m%t==0:
        if t*n<=m:
            print(t)
            exit()
        else:
            t-=1
    else:
        t-=1
# Judge status: Wrong Answer
s = input()

now = s[0]
cnt = 1
i = 1
while True:
    if s[i] != now:
        cnt += 1
        now = s[i]
        i += 1
    else:
        now = now + s[i]
        cnt += 1
        i += 2
        if i > len(s)-1:
            cnt -= 1
    if i >= len(s):
        break
print(cnt)
# Judge status: Accepted
s = input()
st = []
for e in s:
  if e == 'B':
    if len(st) != 0:
      st.pop()
  else:
    st.append(int(e))
print(''.join(map(str,st)))
# Judge status: Accepted
str = 'abcdefghijklmnop'
def bt(n,m,s):
  if n == 0:
    print(s)
    return
  for c in range(m):
    bt(n-1,m,s+str[c])
  #introduce another character
  bt(n-1,m+1,s+str[m])
n = int(input())
bt(n,0,'')
# Judge status: Accepted
n = int(input())
ls = [list(map(int,input().split())) for _ in range(n)]
p = 0
for i in range(n):
    j = n-1-i
    q = ls[j][1] - ((ls[j][0]+p)%ls[j][1])
    if q == ls[j][1]:
        q = 0
    p += q
print(p)
# Judge status: Accepted
import sys

import math
import itertools

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
p = na()
q = na()
l = list(itertools.permutations(list(range(1, n+1))))
print(abs(l.index(tuple(p)) - l.index(tuple(q))))
# Judge status: Accepted
# 入力
n = int(input())
A = list(map(int,input().split()))

A.sort()

ans = 0
can = 1 # lastの数が後何回足されうるか
will = n-1 # 次に足されるであろう数のindex
for i in range(n-1):
    ans += A[will]
    can -= 1
    if can == 0:
        # 足されきったら一つ小さい数へ
        can = 2 # 最大値以外は2回足されうる
        will -= 1
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
ans = 0

for i in range(n-1):
    x = set(s[:i+1])
    y = set(s[i+1:])
    ans = max(ans,len(x&y))
    
print(ans)
# Judge status: Wrong Answer
P, Q, R = map(int, input().split(' '))
print(min([P+Q, Q+R]))
# Judge status: Accepted
a, b, c = map(int, input().split())
K = int(input())
S = sum([a, b, c])
m = max([a, b, c])
S -= m
for i in range(K):
  m = m * 2
  #print(m)
print(S + m)
# Judge status: Wrong Answer
N,M=map(int,input().split())
PS=[]
for i in range(M):
  x,y=input().split()
  PS.append((int(x),y))
ac=[0]*N
wa=[0]*N
for i in range(M):
  if PS[i][1]=="AC" and ac[PS[i][0]-1]==0:
    ac[PS[i][0]-1]=1
  elif PS[i][1]=="WA" :
    if ac[PS[i][0]-1]!=1:
      wa[PS[i][0]-1]+=1
sac=sum(ac)
swa=sum(wa)
print(sac,swa)
# Judge status: Wrong Answer
a=list(map(int,input().split()))
if a.count(5)==2:
    if a.count(7)==1:
        print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
t=int(input())
f=[]
for i in range(t):
    s=input()
    f.append(s)
print("AC"+' '+'*'+' '+str((f.count("AC"))))
print("WA"+' '+'*'+' '+str((f.count("WA"))))
print("TLE"+' '+'*'+' '+str((f.count("TLE"))))
print("RE"+' '+'*'+' '+str((f.count("RE"))))
# Judge status: Wrong Answer
import string

N = int(input())
char_list = string.ascii_lowercase
char_list = char_list[:-1]
char_list = 'z' + char_list

tmp = 0
count = 0
ans = ''
while 1:
    before = tmp
    count += 1
    tmp += 26**count
    if before < N <= tmp:
        tmp = N
        while 1:
             ans = char_list[tmp%26] + ans
             tmp = tmp // 26
             count -= 1
             if count == 0:
                 break
        break
    else:
        pass

print(ans)
# Judge status: Wrong Answer
s=input()

if s<="2019/04/30":
  print("HEISEI")
else:
  print("TBD")