peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
for i in range(len(s)):
    if (i%2==0 and s[i]=="L") or (i%2==1 and s[i]=="R"):
        ans = "No"
        break
else:
    ans = "Yes"
print(ans)
# Judge status: Wrong Answer
a,b = map(int,input().split())
result = a+b
if result % 3==0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Wrong Answer
# 頭から順にaに変えていく

import sys
readline = sys.stdin.readline

S = list(readline().rstrip())
K = int(readline())

z = ord("z")
for i in range(len(S) - 1):
  # aにするためのコストを求める
  cost = z + 1 - ord(S[i])
  if cost < K:
    S[i] = "a"
    K -= cost

K %= 26
nex = ord(S[-1]) + K
if nex > ord("z"):
  nex -= 26
S[-1] = chr(nex)

print("".join(S))
# Judge status: Accepted
from numpy.linalg import solve

x, y = map(int, input().split())
left = [[1, 1],
        [2, 4]]

right = [x, y]

a = solve(left, right)

left = [[1, 1],
        [4, 2]]

right = [x, y]
b = solve(left, right)
if (a[0] >= 0 and a[1] >= 0) or (b[0] >= 0 and b[1] >= 0):
    if (a[0].is_integer() is True and a[1].is_integer() is True) or (b[0].is_integer() is True and b[1].is_integer() is True):
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Accepted
def is_secure(S):
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            return 'Bad'
    return 'Good'


print(is_secure(input()))
# Judge status: Accepted
a,b=map(int,input().split())
a=(a-2)%13
b=(b-2)%13
print(["Draw","Bob","Alice"][((a==b)+1)*((a<b)-(b<a))])
# Judge status: Wrong Answer
n, k = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
if k >= n:
    print(0)
else:
    print(sum(H[max(0, -k-1):]))
# Judge status: Accepted
import collections

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]

cnt_list = collections.Counter(A)
total = sum(A)
for i in range(Q):
    cnt_list[BC[i][1]] += cnt_list[BC[i][0]]
    total += (BC[i][1] - BC[i][0]) * cnt_list[BC[i][0]]
    cnt_list[BC[i][0]] = 0
    print(total)
# Judge status: Wrong Answer
N = int(input())
a = [int(input()) for _ in range(N)]

ans, nex = 1, a[0]
while ans < N or nex == 2:
	 nex = a[nex - 1]
	 ans += 1
	 
print(ans if ans != N else -1)
# Judge status: Accepted
N = int(input())
a = [int(k) for k in input().split()]
a.sort(reverse = True)
sub = 0

for i in range(N//2):
    sub += a[2*i] - a[2*i +1]
if (N%2 == 1):
    sub += a[-1]

print(sub)
# Judge status: Accepted
q,h,s,d = map(int,input().split())
n = int(input())
a=min(q*8,h*4,s*2,d)
b=min(q*4,h*2,s)
ans = 0
if n%2==1:
    ans += b
    ans += min(b*(n-1),a*(n//2))
else:
    ans += min(b*n,a*(n//2))
print(ans)
# Judge status: Accepted
a1,a2,a3 = map(int,input().split())

if a1 + a2 + a3 >= 22:
    print("bust")
else:
    print("win")
# Judge status: Accepted
## coding: UTF-8
#DP
N = int(input())
U = list(map(int,input().split()))
D = list(map(int,input().split()))

#dp = [[0] * 2] * N #これだとアドレスごとコピーされている
dp = []
for i in range(N):
    dp.append([0] * 2)
dp[0][0] = U[0]
dp[0][1] = U[0] + D[0]
for i in range(1, N):
    dp[i][0] = dp[i-1][0] + U[i]
    dp[i][1] = max(dp[i-1][1], dp[i][0]) + D[i]
    #print(dp)
print(dp[N-1][1])
# Judge status: Accepted
n, m = (int(x) for x in input().split())
a = 0
if n < m // 2:
    a += n
    m -= n * 2
    a += m // 4
else:
    a += m // 2
print(a)
# Judge status: Accepted
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,X,T = MI()
print(T*((N+X-1)//X))
# Judge status: Wrong Answer
s,w = map(int,input().split())	
if s>w:
  print("safa")
else:
  print("unsafa")
# Judge status: Accepted
a, b, c, k = map(int, input().split())

ans = a
if k < a:
    ans = k
    
if k > a + b:
    ans = ans - (k - (a+b))

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

N, K = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)
minA = min(A)

A = sorted(A)
minA = min(A)

if N == K:
  print(1)
  exit()




for i in range(N):
    if A[i] != minA:
        start = i
        length = (N-start)
        if length % (K-1) != 0:
            print((math.ceil(length /(K-1))))
            exit()
        else:
            print(int((length / K-1)+1))
            exit()
# Judge status: Accepted
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

s,t=s1()
a,b=n1()
u=s0()
if s==u:
    a=a-1
else:
    b=b-1
print(a,b)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
total = 0
for i in a[1:]:
    total ^= i

a[0] = total
print(*a)
# Judge status: Wrong Answer
x = int(input())
import math

while True:
  if(math.sqrt(x).is_integer()):
    print(x)
    exit()
  else:
    x -= 1
# Judge status: Accepted
a = int(input())
s = input()

if a >= 3200:
  print(s)
else:
  print("red")
# Judge status: Accepted
import numpy as np
 
N = input()
X = list(map(int, input().split()))
ans=9999999
for P in range(0, 101):
  sum = np.sum(list(map(lambda x: (x-P)**2, X)))
  ans = min(ans, sum)
    
print(ans)
# Judge status: Accepted
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)
from string import ascii_lowercase

n,k = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().split()))
a.sort()

print(sum(a[:k]))
# Judge status: Accepted
N=int(input())
s=[input() for _ in range(N)]
s.sort()

ans=1
k=1
for i in range(N-1):
    if s[i]==s[i+1]:
        k=k*(-1)
    else:k=1
    ans+=k
        
print(ans)
# Judge status: Wrong Answer
N=int(input())
N=(str(N))
j_count=0
for i in range(0,3):
    if N[i]==N[i+1]:
        j_count+=1
if j_count>=2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, K = map(int, input().split())
D = set(map(str, input().split()))

while set(str(N)) & D:
    N += 1
print(N)
# Judge status: Accepted
p=2019
s=input()
l=len(s)
amari=[0]*l
count=[0]*p

ruijo=1

for i in range(l):
    suji=int(s[l-i-1])
    amari[i]=(suji*ruijo)%p
    ruijo*=10
    ruijo%=p

gen=0
count[0]+=1
for i in range(l):
    gen+=amari[i]
    gen%=p
    count[gen]+=1
    #print(gen)

ans=0

for c in count:
    if(c>1):
        ans+=c*(c-1)//2

print(ans)
# Judge status: Wrong Answer
import itertools

N = int(input())
P_ar = list(map(int,input().split()))
Q_ar = list(map(int,input().split()))

List = list(map(list,list(itertools.permutations(range(N)))))

for i in range(N):
  P_ar[i]-=1
  Q_ar[i]-=1

a=-1
b=-1

for i in range(len(List)):
  if List[i]==P_ar:
    a=i
    break

for i in range(len(List)):
  if List[i]==Q_ar:
    b=i
    break
# Judge status: Accepted
s = input()
k = int(input())
loop = ord('z') + 1
remaining = k
ans = []
for c in s:
    if c == 'a':
        ans.append(c)
        continue
    r = loop - ord(c)
    if r <= remaining:
        ans.append('a')
        remaining -= r
    else:
        ans.append(c)
if remaining > 0:
    remaining %= 26
    ans[-1] = chr(ord(ans[-1]) + remaining)
print(''.join(ans))
# Judge status: Wrong Answer
import queue

n = int(input())


q = queue.Queue()

for i in range(1,10):
    q.put(i)

x = 0
for i in range(n):
    x = q.get()
    l = x % 10
    print(x,l)
    if l != 0:
        q.put(x*10 + l - 1)
    q.put(x*10 + l)
    if l != 9:
        q.put(x*10 + l + 1)
        
#while not q.empty():
#    print (q.get())
    
print(x)
# Judge status: Wrong Answer
n = int(input())
n_str = str(n)
num_0to5 = []
num_6to9 = []

ans = 0

kurisagari_flg = False

for x in list(n_str):
    if int(x)<=5:
        num_0to5.append(int(x))
        ans += int(x)
        kurisagari_flg = False
    else:
        num_6to9.append(int(x))
        ans += 11 - int(x)
        if kurisagari_flg:
            ans -= 2
        kurisagari_flg = True
        
print(ans)
# Judge status: Accepted
N, K, Q = map(int,input().split())
a = []
b = [0] * N
for i in range(Q):
    A = int(input())
    a.append(A)

for i in a:
    b[i - 1] += 1
for i in b:
    if i > Q - K:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
a,b=map(int,input().split())
c=str(a)*b
d=str(b)*a
n=[c,d]
n.sort()
print(n[0])
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

from fractions import gcd
import math

llis = [0]
rlis = [0]
for i in range(n):
    llis.append(gcd(llis[-1],a[i]))
    rlis.append(gcd(rlis[-1],a[n-i-1]))

mx = 0
for i in range(n):
    cd = gcd(llis[i],rlis[n-i-1])
    mx = max(mx,cd)

print(mx)
# Judge status: Accepted
a = input()
b = input()
c = 0
for i in range(len(a)):
  if a[i] != b[i]:
    c += 1
print(c)
# Judge status: Accepted
from collections import deque

N, M = map(int, input().split())
graph = [[] for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
# print(graph)

res = [-1] * (N)
que = deque()
que.append(0)

while que:
    i = que.popleft()
    for j in graph[i]:
        if res[j] == -1:
            res[j] = i
            que.append(j)

print("Yes")
for i in res[1:]:
    print(i+1)
# Judge status: Accepted
ss = input()

tmp = ""
last = ""
res = 0

for s in ss:
    tmp += s
    if tmp == last:
        continue
    
    last = tmp
    tmp = ""
    res+=1
print(res)
# Judge status: Wrong Answer
N,M=map(int,input().split())
import heapq
A=list(map(int,input().split()))
heapq.heapify(A)
BC=[]
for i in range(M):
  B,C=map(int,input().split())
  BC.append((B,C))
BC.sort(key=lambda x:x[1],reverse=True)
import bisect
A.sort()
now=0
D=[0]*N
for i in range(M):
  B=BC[i][0]
  C=BC[i][1]
  for j in range(now,min(now+B,N-1)):
    D[j]=C
  now+=B
  if now>N-1:
    break

for i in range(N):
  a=A[i]
  d=D[i]
  if d>a:
    A[i]=d
  else:
    break
print(sum(A))
# Judge status: Wrong Answer
a = list(input())
even_number = [x for x in range(0,101,2)]
tmp_list = []
tmp_set = set(a)

tmp_list = [a.count(x) for x in tmp_set]
if all(x % 2 == 0 for x in tmp_list) == True:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
A = [abs(753 - int(x+y+z)) for x, y, z in zip(S[:], S[1:], S[2:])]
answer = min(A)
print(answer)
# Judge status: Wrong Answer
s = map(int,input().split())
m = 10000000
for p in s:
  t = 0
  for x in s:
    t+=(x-p)**2
  m = min(t,m)
print(m)
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]
ans = [0]*n

for i in range(n-1, -1, -1):
  now = 0
  for j in range(i+i+1, n, i+1):
    now += ans[j]
  if now % 2 != a[i]:
    ans[i] = 1

print(sum(ans))
for i in range(n):
  if ans[i] == 1:
    print(i+1)
# Judge status: Wrong Answer

n = int(input())

bit = []
while n != 0:
    bit.append(-(-n % -2))
    n = -(-n // -2)

for i in range(len(bit) - 1, -1, -1):
    print(bit[i], end = "")
print()
# Judge status: Wrong Answer
n,x=map(int,input().split())

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

a.sort()

s=0
i=0

if n==0:
    print(0)
    exit()
elif sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<x:
        s+=a[i]
        i+=1

print(i-1)
# Judge status: Wrong Answer
n = int(input())
ans = [0]*(n+5)

for x in range(1,10):
    for y in range(1,10):
        for z in range(1,10):
            temp = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n>=temp:
                print(x,y,z, temp)
                ans[temp]+=1


for i in range(1,n+1):
    print(ans[i])
# Judge status: Accepted
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    A=sorted(list(map(int,input().split())), reverse=True)
    k=int(input())

    for i in range(1,k+1):
        A[0]*=2



    print(sum(A))




resolve()
# Judge status: Accepted
a,b=map(int,input().split())
if a==b:
  print(2*a)
elif a>b:
  print(a+a-1)
else:
  print(b+b-1)
# Judge status: Accepted
n = int(input())
v = list(map(int, input().split()))
v.sort()

mean = v[0]

for i in range(1, len(v)):
    mean = (mean + v[i]) / 2

print(mean)
# Judge status: Wrong Answer
import sys

readline = sys.stdin.readline
W, H, N = map(int, readline().split())
lb = [0, 0]
rt = [W, H]
for _ in range(N):
    x, y, a = map(int, readline().split())
    if a == 1 and lb[0] < x:
        lb[0] = x
    elif a == 2 and rt[0] > x:
        rt[0] = x
    elif a == 3 and lb[1] < y:
        lb[1] = y
    elif a == 4 and rt[1] > y:
        rt[1] = y

print(max((rt[0]-lb[0])*(rt[1]-lb[1]), 0))
# Judge status: Accepted
#!/usr/local/bin/python3

N, A, B = map(int, input().split())
S = input()
cur_rank = 1
world_cur_rank = 1

for s in S:
    pass_cond = cur_rank <= A+B
    if s == 'a' and pass_cond:
        print('Yes')
        cur_rank += 1
    elif s == 'b' and pass_cond and world_cur_rank <= B:
        print('Yes')
        cur_rank += 1
        world_cur_rank += 1
    else:
        print('No')
# Judge status: Accepted
a,b,c = map(int, input().split())

if a + b + c >= 22:
    print('bust')
else:
    print('win')
# Judge status: Accepted
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    s = input().strip()
    t = input().strip()
    return N, s, t


def solve(N, s, t):
    for i in range(N, 0, -1):
        sl = N - i
        tr = i
        if s[sl:] == t[:tr]:
            return 2 * N - i
    return 2 * N


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))
# Judge status: Accepted
#-*- using:utf-8 -*-

A, B, C = map(int, input().split())
K = int(input())

for _ in range(K):
    if A >= B:
        B = B*2
    elif B >= C:
        C = C*2
    else:
        C = C*2

if A < B and B < C:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x, y, z = map(int, input().split())
res = (x - z) // (y + z)
print(res)
# Judge status: Accepted
n=int(input())
t,a=map(int,input().split())
x=list(map(int,input().split()))
ans=0
cnt=10**3
for i in range(len(x)):
  s=t-x[i]*0.006
  if abs(s-a)<cnt:
    cnt=abs(s-a)
    ans=i+1
print(ans)
# Judge status: Wrong Answer
A,B = map(int,input().split())
S = input()
print(S[:A],S[A],S[B+1:])
if S[:A].isdigit() and S[A] == "-" and S[B:].isdigit():
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]*n

for i in range(1, n):
    c = 99999999999
    for j in range(max(0, i-k), i):
        c = min(c, dp[j]+abs(h[i]-h[j]))
        
    dp[i] = c
        
print(dp[-1])
# Judge status: Accepted
x, y = map(int, input().split())

cnt = 0

while x <= y:
    x *= 2
    cnt += 1
print(cnt)
# Judge status: Accepted
N = int(input())
numbers = input().split()
numbers = list(map(int,numbers))
numbers = sorted(numbers)
even_numbers = sum(numbers[1::2])
odd_numbers = sum(numbers[0::2])
print(abs(odd_numbers - even_numbers))
# Judge status: Wrong Answer
import bisect

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
sorted(a)
sorted(b)
sorted(c)

total = 0
for i in b:
    a_number = bisect.bisect_left(a, i)
    c_number = n - bisect.bisect_right(c, i)
    total = total +  a_number * c_number
print(total)
# Judge status: Wrong Answer
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(x*k + y*(n-k))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans = float('inf')
sum_A = sum(A)
hoge = 0


for i in range(N-1):
  hoge = hoge + A[i]
  ans = min(ans,abs(sum_A - (hoge*2)))

print(ans)
# Judge status: Accepted
A,B,C=map(int,input().split())
if A*C<=B:
    print(C)
else:
    print(B//A)
# Judge status: Accepted
X = int(input())
x = 100
c = 0
while x < X:
    c += 1
    x += int(x * 0.01)
print(c)
# Judge status: Wrong Answer
N = int(input())
hs = list(map(int, input().split()))

costs1 = 0
costs2 = abs(hs[1] - hs[0])
for i in range(2, N):
  costs1, costs2 = min(costs1 + abs(hs[i] - hs[i - 2]), costs2 + abs(hs[i] - hs[i - 1])), costs1
  
print(costs2)
# Judge status: Accepted
import heapq
from sys import exit
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = sorted([tuple(map(int, input().split())) for _ in range(M)], key=lambda x: x[1], reverse=True)
heapq.heapify(A)

ans = sum(A)
for b, c in BC:
    for _ in range(b):
        if len(A) == 0:
            print(ans)
            exit()
        a = heapq.heappop(A)
        if a < c:
            ans += c - a
        else:
            print(ans)
            exit()
print(ans)
# Judge status: Accepted
Q,H,S,D=map(int,input().split(' '))
N = int(input())
l1 = min(4*Q,2*H,S)
l2 = min(2*l1,D)
if N==1:
    print(l1)
elif N%2==0:
    print(N//2*l2)
else:
    print(N//2*l2+l1)
# Judge status: Wrong Answer
def nyu():
    N,K = map(int,input().split())
    A = [list(map(int,input().split())) for _ in range(N)]
    return N,K,A

def kansu(N,K,A):
    
    sum = 0
    ans = -1


    for a in range(len(A)):
        sum += A[a][1]
#        print(sum,A[a][1])
        if (K <= sum):
            ans = A[a][0]
            break
    print(ans)




N,K,A = nyu()
kansu(N,K,A)
# Judge status: Accepted
a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:print('Possible')
else:print('Impossible')
# Judge status: Accepted
N = int(input())

print(sum(
  i
  for i in range(1, N + 1)
  if i % 3 != 0 and i % 5 != 0
))
# Judge status: Accepted
s = int(input())
s1 = s // 100
s2 = s % 100
c = 0
l = ["NA","YYMM","MMYY","AMBIGUOUS"]
if 1<=s2<=12:
  c += 1
if 1<=s1<=12:
  c += 2
print(l[c])
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if b-a == c-b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))

max_L = max(L)
sum_excluded_max_L = sum(L) - max_L

answer = 'Yes' if max_L < sum_excluded_max_L else 'No'

print(answer)
# Judge status: Wrong Answer
a,b,c = input().split()
 
score = 1
if a != b:
	score = score + 1
elif b !=c:
	score = score + 1
else:
	score = score
print(score)
# Judge status: Accepted
N=int(input())

for i in range(N,1000):
	if i%111 == 0:
		print(i)
		break
# Judge status: Accepted
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    N = input_int()
    ans = ""
    while N:
        r = N % 2
        if r < 0:
            r += 2
        N = (N - r) // (-2)
        ans += str(r)
    ans = ans[::-1]
    if ans:
        print(ans)
    else:
        print(0)
    return


if __name__ == "__main__":
    main()
# Judge status: Accepted
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = sum(a[1:2*n:2])
print(ans)
# Judge status: Accepted
from collections import deque
s=input()
Q=int(input())
hanten = 0
mae = deque()
ushiro = deque()
for i in range(Q):
	q=input()
	if q=="1":
		hanten ^= 1
	else:
		if q[2] == "1":
			if hanten == 0:
				mae.appendleft(q[4])
			else:
				ushiro.append(q[4])
		else:
			if hanten == 0:
				ushiro.append(q[4])
			else:
				mae.appendleft(q[4])
if hanten == 0:
	print("".join(mae) + s + "".join(ushiro))
else:
	print(("".join(mae) + s + "".join(ushiro))[::-1])
# Judge status: Accepted
import itertools
n, m, q = map(int, input().split())
abcds = [list(map(int, input().split())) for _ in range(q)]
aaa = range(1, m + 1)
ans = 0
for a in itertools.combinations_with_replacement(aaa, n):
    list(a).sort()
    tmp = 0
    for abcd in abcds:
        if a[abcd[1] - 1] - a[abcd[0] - 1] == abcd[2]:
            tmp += abcd[3]
    ans = max(ans, tmp)
print(ans)
# Judge status: Accepted
import itertools
N, K = map(int,input().split())
S = input()
##num = [i for i in range(1,N + 1)]
##for i in itertools.combinations(num, 2):
##    #print(i)
ans = 0
for i in range(1, N):
    if S[i] == S[i - 1]:
        ans += 1

print(min(N -1, ans + K * 2))
# Judge status: Wrong Answer
s = list(input())

if len(s)%2!=0:
  point = int((len(s)-1)/2)
  count = 0
  for i in range(1,int((len(s)-1)/2+1)):
    if s[point-i]!=s[point+i]:
      count += 1
  print(count)
  exit()
elif len(s)%2==0:
  point1 = int(len(s)/2-1)
  point2 = int(len(s)/2)
  count = 0
  for i in range(1,int(len(s)/2-1)):
    if s[point1-i]!=s[point2-i]:
      count += 1
  print(count)
# Judge status: Accepted
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]

ans = 0
for i in range(N):
    if B[i] >= A[i]:
        ans += A[i]
        B[i] -= A[i]
    else:
        ans += B[i]
        continue
    if B[i] > A[i+1]:
        ans += A[i+1]
        A[i+1] = 0
    else:
        ans += B[i]
        A[i+1] -= B[i]
print(ans)
# Judge status: Accepted
inpl = lambda: list(map(int,input().split()))
N = int(input())
A = inpl()
print(sum(A[i]%2 for i in range(0,N,2)))
# Judge status: Accepted
import math

N, M = map(int, input().split())
mod = 10**9+7

if abs(N - M) >= 2:
    print(0)
elif N == M:
    print(((math.factorial(N) % mod) * (math.factorial(M) % mod) * 2) % mod)
else:
    print(((math.factorial(N) % mod) * (math.factorial(M) % mod)) % mod)
# Judge status: Accepted
N = int(input())
s = input()
t = input()
ans = s + t

for i in range(N):
    if(s[i:] == t[:(len(t)-i)]):
        ans = s + t[-i:]

print(len(ans) if s != t else N)
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())

A = 500
B = 100
C = 50
count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            amount = i*A + j*B + k*C
            if amount == x:
                count += 1


print(count)
# Judge status: Accepted
#!/usr/bin/env python3
import math

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

if n == k:
    ans = 1 
elif (n-1)%(k-1)==0:
    ans = (n-1)//(k-1)
else:
    ans = math.ceil(n/(k-1))
print(ans)
# Judge status: Accepted
n = int(input())
l = []
s = 0
for i in range(1,10**7+1):
  if n>=s:
    s += i
    l.append(i)
  else:
    break
if s-n>0:
  a = s-n
  l.remove(a)
for i in l:
  print(i)
# Judge status: Accepted
N, M = map(int, input().split())
h = list(map(int, input().split()))
li = []
for m in range(M):
  a, b = map(int, input().split())
  if h[a-1] < h[b-1]:
    li.append(a)
  elif h[a-1] == h[b-1]:
    li.append(a)
    li.append(b)
  else:
    li.append(b)

answer = N - len(set(li))
print(answer)
# Judge status: Accepted
import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
past = s[n-1]
ima = 0
d = dict()
d[s[n-1]] = 1
now = 10
for i in range(1,n):
    ima = (past+s[n-i-1]*now)%mod
    if ima == 0:
        ans += 1
    if ima in d:
        d[ima] += 1
    else:
        d[ima] = 1
    past = ima
    now = (now*10)%mod

for i in d.values():
    ans += i*(i-1)//2

print(ans)
# Judge status: Accepted


K = int(input())
S = input()
if len(S) <= K:
    print(S)
else:
    print(S[:K] + "...")
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split(" ")))

r = 1

for x in a:
    if(x == 0):
        print(0)
        exit(0)    

for x in a:
    r = r * x
    if(r > 10**18):
        print(-1)
        exit(0)
r = int(r)
print(r)
# Judge status: Accepted
n,c,k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()

bus = 0
vis = [False for i in range(n)]
for i in range(n):
  if vis[i]:
    continue
  vis[i] = True
  x = i
  lim = t[i]+k
  cnt = 1
  bus += 1
  while x < n and cnt <= c:
    if t[x] > lim:
      break
    i = x
    vis[x] = True
    x += 1
    cnt += 1
print (bus)