peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
l, r = map(int, input().split())

ans_list = []
for i in range(l, min(l+2019, r)):
  for j in range(i + 1, min(i + 2019, r + 1)):
    ans = (i * j) % 2019
    ans_list.append(ans)
    if ans == 0:
      break
print(min(ans_list))
# Judge status: Wrong Answer
if __name__ == '__main__':
    n = int(input())
    k = [int(i) for i in input().split()]
    a = 0
    b = 0
    k.sort(reverse=True)
    print(k)
    flag = True
    for i in k:
        if flag == True:
            a+=i
            flag=False
        else:
            b+=i
            flag=True
    print(a-b)
# Judge status: Accepted
k = int(input())
s = input()

if len(s) <= k:
    print(s)
else:
    print(s[:k]+'...')
# Judge status: Accepted
import sys
W,a,b = map(int,input().split())
if W < 0 or W > 100000:
    sys.exit()
if a < 0 or a > 100000:
    sys.exit()
if b < 0 or b > 100000:
    sys.exit()

move = 0
if W + a < b:
    move = b - (W + a)
if W + a > b and W + a < W + b:
    move = 0
if a > b and a < W + b:
    move = 0
if a > W + b and W + a > W + b:
    move = a - (W + b)
print(move)
# Judge status: Accepted
S = input()
for i in range(len(S)):
	if i == len(S)-1:
		print("Good")
		break
	elif S[i] != S[i+1]:
		continue
	else:
		print("Bad")
		break
# Judge status: Accepted
import sys
import math

X = int(sys.stdin.readline())
for i in range(1, 10**5):
    if (X * i) % 360 == 0:
        print(i)
        break
# Judge status: Wrong Answer
sx,sy,tx,ty=map(int,input().split())
print('U'*(ty-sy),end='')
print('R'*(tx-sx),end='')
print('D'*(ty-sy),end='')
print('L'*(tx-sx),end='')
print('L',end='')
print('U'*(ty-sy+1),end='')
print('R'*(tx-sx+1),end='')
print('D'*(ty-sy+1),end='')
print('L'*(tx-sx+1),end='')
print('U')
# Judge status: Accepted
n = int(input())
ans = 0
nex = 0
for i in range(n):
    now = int(input())
    if nex == 1 and now > 0:
        now -= 1
        nex = 0
        ans += 1
    elif nex == 1 and now == 0:
        nex = 0 
    ans += now//2
    if now % 2 == 1:
        nex = 1
print(ans)
# Judge status: Accepted
S = list(input())
L = len(S)
key = list("keyence")

for i in range(0,8):
    if S[0:i] == key[0:i] and S[L-7+i:] == key[i:]:
        print("YES")
        exit()
print("NO")
# Judge status: Accepted
N, M = map(int, input().split())
if 2*N >= M:
    print(M//2)
else:
    print((2*N+M)//4)
# Judge status: Accepted
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    x, y, a, b, c = map(int, input().split())
    print(sum(sorted((sorted(list(map(int, input().split())), reverse=True)[0:x] + sorted(list(map(int, input(
    ).split())), reverse=True)[0:y] + sorted(list(map(int, input().split())), reverse=True)), reverse=True)[0:(x + y)]))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from collections import deque
N,M = map(int,input().split())
l = [[] for _ in range(N+1)]
for _ in range(M):
  a,b = map(int,input().split())
  l[a].append(b)
  l[b].append(a)

ans = 'No'
st = deque([1])
check = [0]*(N+1)
mark = [0]*(N+1)

while st:
  s = st.popleft()
  for t in l[s]:
    mark[t] = s
    check[t] = 1
    st.append(t)
  if sum(check) == N:
    ans = 'Yes'
    break

print(ans)
if ans == 'Yes':
  for i in range(2,N+1):
    print(mark[i])
# Judge status: Accepted
# print('input >>')
R  = int(input())

# print('-----output-----')
print(R * 2 * 3.1415)
# Judge status: Accepted
n,m=map(int,input().split())

sa=set()
sb=set()

for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        sb.add(b)
    if b==n:
        sa.add(a)

if sa&sb:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Judge status: Accepted
S, T = input().split()
A, B = map(int, input().split())
print(*(A-1,B) if S==input() else (A,B-1))
# Judge status: Accepted
a = int(input())

ans = a + a ** 2 + a ** 3

print(ans)
# Judge status: Accepted
N =int(input())
a=N//111
b=N%111
if b!=0:
    x=111*(a+1)
else:
    x=N
print(x)
# Judge status: Accepted
a,b,c,d = map(int, input().split())

if abs(a-c) <=d:
  print("Yes")
elif (abs(a-b) <= d) & (abs(b-c) <= d):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n, x, t = map(int, input().split())

ans = ( (n-1)//x + 1)* t
print(ans)
# Judge status: Wrong Answer
[A, B, C, D] = list(map(int, input().split()))
X = A / D
Y = C / B
if X < Y or (X < 0 and Y < 0):
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
S = input()
flag = True
if (S[2] != S[3]):
    flag = False
if (S[4] != S[4]):
    flag = False

if flag:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
hp, atk = input().split()

hp = int(hp)
atk = int(atk)

value = 0

numlist = list((input().split()))

numlist = list(map(int, numlist))

numlist = sorted(numlist, reverse=True)

for i in range(atk):
    value = value + numlist[i]
    if value > hp:
        print("Yes")
    else:
        if i+1 == atk:
            print("No")
        else:
            continue
# Judge status: Wrong Answer
x,y=map(int,input().split())
a=0
for i in range(min(x,y),max(x,y)):
    if x%y==0 or y%x==0:
        print(-1)
        a=1
        break
    if i%x==0 and i%y!=0:
        print(i)
        a=1
        break
if a==0:
    print(-1)
# Judge status: Accepted
N, K = map(int, input().split())
D = {}
for _ in range(N):
  a, b = map(int, input().split())
  if a not in D: D[a] = 0
  D[a] += b

D = sorted(list(D.items()))
k = 0
for a, b in D:
  k += b
  if k>=K:
    print(a)
    exit()
# Judge status: Accepted
import math
import sys
n = int(input())
li=[input()]
for i in range(n-1):
    li.append(input())
li.sort()
cnt = 0
tmp = 1
li.append('')
for i in range(n):
    if (li[i] == li[i + 1]):
        tmp += 1
    else:
        if(cnt<tmp):
            cnt=tmp
        tmp = 1
tmp=1
for i in range(n):
    if (li[i] == li[i + 1]):
        tmp += 1
    else:
        if (cnt == tmp):
                print(li[i])
        tmp = 1
# Judge status: Accepted
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
A, B = map(list, zip(*AB))

A.sort()
B.sort()

def median(a):
    n = N
    return a[(n+1)//2-1] if n%2 else (a[n//2-1]+a[n//2])/2

A_mid = median(A)
B_mid = median(B)

r = int((B_mid-A_mid) * [2, 1][N%2]) + 1

print(r)
# Judge status: Accepted
S = input()

index1 = (len(S)-1)//2
index2 = (len(S)+3)//2
S_sub1 = S[:index1]
S_sub2 = S[index2-1:]

if S == S[::-1] and S_sub1 == S_sub1[::-1] and S_sub2 == S_sub2[::-1]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
S = input().strip()
T = input().strip()
F = {}
flag = 0
for i in range(len(S)):
    a = S[i]
    b = T[i]
    if a not in F:
        F[a] = b
    if F[a] != b:
        flag = 1
        break
    for c in F:
        if c!=a and F[c]==b:
            flag = 1
            break
if flag==1:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n, m = map(int, input().split())
lmax, rmin = map(int, input().split())
for i in range(1, m):
  l, r = map(int, input().split())
  lmax = max(lmax, l)
  rmin = min(rmin, r)
print(max(0, rmin-lmax+1))
# Judge status: Accepted
x = int(input())

s = 0
i = 1
while True:
    s += i
    if s >= x:
        print(i)
        break
    i += 1
# Judge status: Wrong Answer
x, y = map(int, input().split())
print(x + y/2)
# Judge status: Accepted
def main(test_case,clear_case):
    if test_case <= clear_case:
      return "Yes"
    else:
      return "No"
    
if __name__ == "__main__":
    input_num = input()
    num1 = int(input_num.split()[0])
    num2 = int(input_num.split()[1])
    print(main(num1,num2))
# Judge status: Accepted
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
x_max = x[-1]
y_min = y[0]
if max(X, x_max) < min(Y, y_min):
    print('No War')
else:
    print('War')
# Judge status: Accepted
def main():
    S, W = map(int, input().split())
    if S <= W:
        print("unsafe")
    else:
        print("safe")
    return 0

if __name__ == '__main__':
    main()
# Judge status: Accepted
n=int(input())
t,a=map(int,input().split())
H=list(map(int,input().split()))
newH=[(t-x*0.006,i) for i,x in enumerate(H)]
newH=sorted(newH)
from bisect import bisect_left, bisect_right
Ht=[newH[i][0] for i in range(n)]
Hi=[newH[i][1] for i in range(n)]
i=bisect_left(Ht, a)
if i==0:
    ans=Hi[0]+1
elif i==n:
    ans=Hi[n-1]+1
else:
    if abs(a-Ht[i-1])>abs(a-Ht[i]):
        ans=Hi[i]+1
    else:
        ans=Hi[i-1]+1
print(ans)
# Judge status: Accepted
import collections

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

c = collections.Counter(A)

ans = 0
for i in set(A):
    if i > c[i]:
        ans += c[i]
    if i < c[i]:
        ans += (c[i] -i)
print(ans)
# Judge status: Accepted
A,B = map(int,input().split())
x = 1
ans = 0
while x < B:
    x += A-1
    ans += 1
print(ans)
# Judge status: Wrong Answer
def checkTrans(s, t):
    m = {}
    for sc, tc in zip(s, t):
        if tc in m:
            if m[tc] != sc:
                return False
        else:
            m[tc] = sc

    return True

s = input()
t = input()

if checkTrans(s, t):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a = int(input())
dum = a//2
dum = a - dum
print(dum/a)
# Judge status: Accepted
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**9


if __name__ == "__main__":
    s = int(input())
    MOD = 10**9 + 7
    dp = [0]*(s + 1)
    if s>=3:
        dp[3] = 1
    for i in range(4,s+1):
        dp[i] = (dp[i-3] + dp[i-1])%MOD
    print(dp[s])
# Judge status: Accepted
int1 = lambda x: int(x) - 1

N, M = map(int, input().split())

red = [True] + [False] * (N-1)
n_ball = [1] * N

for _ in range(M):
    x,y = map(int1, input().split())
    if red[x]:
        red[y] = True
        n_ball[x] -= 1
        n_ball[y] += 1
        if n_ball[x] == 0:
            red[x] = False
    else:
        n_ball[x] -= 1
        n_ball[y] += 1

print(sum(red))
# Judge status: Wrong Answer
n,l = map(int,input().split())
lst = 0
if l>=0:
    for i in range(1,n+1):
        lst+=l+(i-1)
    a = lst - l
if l < 0 and l+n-1 >=0:
        for i in range(1,n+1):
            if l+i-1 == 0:
                lst+=l+(i-1)
                a = lst
if l+n-1 <0:
    for i in range(1,n+1):
        lst+=l+(i-1)
        a = lst - (l+n-1)
print(a)
# Judge status: Accepted
import math

if __name__ == "__main__":
    K = int(input())
    A, B = map(int, input().split())
    for i in range(A, B+1):
        if i % K == 0:
            ret = "OK"
            break
        else:
            ret = "NG"
    print(ret)
# Judge status: Accepted
a, b, c = map(int, input().split())
print("Yes" if (a + b) >= c else "No")
# Judge status: Accepted
N,K,Q=map(int,input().split())
pts = [K-Q]*N
for _ in range(Q):
    A = int(input())
    pts[A-1] += 1

for i in range(N):
    if pts[i] > 0:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
import numpy as np
import math
n=int(input())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
a=np.array(a, dtype=object)
ans=0
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    else:
      x= (a[i]-a[j])**2
      hei=math.sqrt(sum(x))
      ans+= hei/n
print(ans)
# Judge status: Accepted
#https://atcoder.jp/contests/abc171/tasks/abc171_b
[n, k]=[int(i) for i in input().split()]
p=[int(i) for i in input().split()]

p.sort()


sum=0
for i in range(k):
    sum+=p[i]

print(sum)
# Judge status: Wrong Answer
a = list(map(int, input().split()))
cnt = 1
for i in a:
  if a == 0:
    print(cnt)
    cnt += 1
# Judge status: Accepted
def main():
    N, L = (int(i) for i in input().split())
    s = sum(L + i for i in range(N))
    mi = 10**9
    ans = -1
    for i in range(N):
        eat = L + i
        if abs(eat) < mi:
            mi = abs(eat)
            ans = s - eat
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import collections

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

def combinations_count_two(n):
    if n < 2:
        return 0
    else:
        return (n * (n - 1)) // 2

counter = collections.Counter(A)

for val in counter.values():
    all_comb += combinations_count_two(val)

for i in A:
    ans = all_comb - combinations_count_two(counter[i]) + combinations_count_two(counter[i] - 1)
    print(ans)
# Judge status: Wrong Answer
N = int(input())
s = N * (N-1)
p = 10 ** (N-2)
d = s * p
ans = d % (10 ** 9 + 7)
print(ans)
# Judge status: Accepted
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n, a, b = map(int, readline().rstrip().split())
    mod = 10 ** 9 + 7

    ans = pow(2, n, mod) - 1

    nca, ncb = 1, 1

    for i in range(b):
        ncb = ncb * (n - i) % mod
        ncb *= pow(i + 1, mod - 2, mod)
        if i + 1 == a:
            nca = ncb

    print((ans - (nca + ncb)) % mod)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(1,10):
    for j in range(1,10):
        if n == (i*j):
            ans = 1
            break
if ans == 1:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
import numpy as np

W, H, N = map(int, input().split())

ze = np.ones((W, H))

for i in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        ze[:x, :] = 0
    elif a == 2:
        ze[x+1:, :] = 0
    elif a == 3:
        ze[:, :y] = 0
    elif a == 4:
        ze[:, y+1:] = 0

print(np.sum(ze))
# Judge status: Accepted
n = int(input())
if 1 <= n and n <= 999:
  print("ABC")
else:
  print("ABD")
# Judge status: Wrong Answer
if __name__ == "__main__":

    N=int(input())

    a = N * (N-1) * 10 ** (N-2)
    a = a  % (10 ** 9 + 7)

    print(a)
# Judge status: Wrong Answer
A, B = map(int, input().split())

M = max(A, B)
m = min(A, B)
ans = 0
tmp = m

l = []
for i in range(2, int(-(-m**0.5//1))+1):
    if tmp % i == 0 and M % i == 0:
        ans += 1
        l.append(i)
        while tmp % i == 0:
            tmp //= i

if m != 1:
    ans += 1

if ans == 0 and M % m == 0:
    ans += 1

print(ans)
# Judge status: Wrong Answer
n = int(input())
A =[int(x) for x in input().split()]
ans = [0] * n
for i in range(n-1):
    ans[A[i]-1] +=1

for i in ans:
    print(ans[i])
# Judge status: Accepted
H=int(input())
W=int(input())
N=int(input())
K=H
if K<W: K=W
sum = 0
ans= 0
for i in range(1,K+1):
  if sum < N:
    sum += K
    ans = i
    #print(ans, K)
print(ans)
# Judge status: Wrong Answer
import itertools

n = int(input())
ans_d = {i: 0 for i in range(1,10001)}

p = itertools.product(range(1, 100), range(1, 100), range(1, 100))

for x, y, z in p:
    cnt = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (x * z)
    if cnt <= 10000:
        ans_d[cnt] += 1

for i, j in ans_d.items():
    print(i,j)
    if i == n:
        break
# Judge status: Accepted
N = int(input())
H = [int(x) for x in input().split()]
dp = [0]*N
dp[0] = 0
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
    
print(dp[N-1])
# Judge status: Wrong Answer
n,m = map(int,input().split())
x_y = [list(map(int,input().split())) for _ in range(m)]

start = 1
aka_list = [1]
for i in range(m):
    if x_y[i][0] == start:
        if start == 1:
            aka_list.remove(1)
        aka_list.append(x_y[i][1])
        start = x_y[i][1]
balls = [1]*n
for i in range(m):
    balls[x_y[i][0]-1] -= 1
    balls[x_y[i][1]-1] += 1

count = 0
for i in range(len(aka_list)):
    if balls[aka_list[i]-1]:
        count += 1
print(count)
# Judge status: Wrong Answer
n = input()
n.replace("2017","2018")
print(n)
# Judge status: Accepted
n=int(input())
w=[input() for i in range(n)]
m=w[0][-1]
for i in range(1,n):
  if w.count(w[i])==1 and m==w[i][0]:
    m=w[i][-1]
  else:
    print('No')
    exit()
print('Yes')
# Judge status: Accepted
a, b = map(int, input().split())

if b > a >= 0 or a < b <= 0:
    print(abs(a-b))
elif a > b > 0 or 0 > a > b:
    print(abs(a-b)+2)
else:
    print(abs(abs(a)-abs(b))+1)
# Judge status: Wrong Answer
import math
A,B  = list(map(int,input().split()))
ans  = 1
c = 0
if B <= A:
    print("1")
else:
    while ans < B:
        ans += A-1
        c += 1
    print(c)
# Judge status: Wrong Answer
n = int(input())
if n > 1:
  ans = 1
else:
  ans = 0
i = 2
while i<=10**6:
    
  if n % i == 0:
    ans+=1
    n //= i

  i += 1
print(ans)
# Judge status: Accepted
import math

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

count = [0]*N
for i in range(N):
    count[A[i] - 1] += 1

sum = 0
for i in range(N):
    t = count[i]
    if t >= 2:
        sum += math.factorial(t) // (math.factorial(t - 2) * 2)

for i in range(N):
    t = count[A[i] - 1]
    if t > 1:
        print(sum - t + 1)
    else:
        print(sum)
# Judge status: Wrong Answer
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
ep = K
fp = 0
bs = np.prod(A[fp:ep])
for i in range(1, N - K + 1):
    s = np.prod(A[fp + i: ep + i])
    if s > bs:
        print('Yes')
    else:
        print('No')
    bs = s
# Judge status: Accepted
A, B, X = map(int, input().split())
print("YNEOS"[not (A<=X<=A+B)::2])
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
def cal(A,b):
    a = 0
    for i in range(len(A)):
        a += abs(A[i] - b)
    return a
#cal(A,b)の値の最小値
A_2 = A
for i in range(N):
    A_2[i] = A[i] - (i+1)
A_2.sort()

if N%2 == 0:
    cnum = N//2 - 1
    chu = A_2[cnum]
else:
    cnum = (N-1)//2
    chu = A_2[cnum]
ans = cal(A_2,chu)
print(ans)
# Judge status: Wrong Answer
from statistics import median

t=int(input())
n=t
low=list()
high=list()
while t!=0:
     t-=1
     L,H=list(map(int,input().split()))
     low.append(L)
     high.append(H)
diff=int(median(high)-median(low))
if n%2 == 0:
     ans=(diff*2)+1
     print(ans)
else:
     ans=diff+1
     print(ans)
# Judge status: Wrong Answer
A,B,C=map(int,input().split())
ichi=10*A+B+C
two=A+10*B+C
print(max(ichi,two))
# Judge status: Accepted
s = int(input())

x1 = 0
y1 = 0
x2 = 10 ** 9
y2 = 1

if s < 10 ** 9:
    y3 = 0
    x3 = s
else:
    mod = s % 10 ** 9
    if mod == 0:
        y3 = s // 10 ** 9
        x3 = 0
    else:
        y3 = s // 10 ** 9 + 1
        x3 = 10 ** 9 - mod

print(x1, y1, x2, y2, x3, y3)
# Judge status: Accepted
d = int(input())
C = list(map(int, input().split()))
T = []
for i in range(d):
    S = list(map(int, input().split()))
    index = S.index(max(S))
    T.append(index+1)
for t in T:
    print(t)
# Judge status: Wrong Answer

S=input()
l=set(S)
if len(l)==4:
    print('Good')
else:
    print('Bad')
# Judge status: Wrong Answer
a,b,c = map(int, input().split())

if a <= c <= b:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n = input()
if len(set(n))<= 2:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
s = input()
if s == "ABC":
    print("ARC")
else:
    print("ARC")
# Judge status: Accepted
X = int(input())
print('Yes' if X >= 30 else 'No')
# Judge status: Accepted
s = sorted(list(input()))
t = sorted(list(input()), reverse = True)
if s < t:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N=input()
N=int(N[0])*int(N[1])
print("Yes" if N%9==0 else "No")
# Judge status: Wrong Answer
n = int(input())
lst = list(map(int, input().split()))
m = []
for i, l in enumerate(lst,start=1):
    m.append(l-i)
ave = int(sum(m)/n)

cand = []
for b in range(ave-3, ave+3):
    tmp = sum([abs(val-i-b) for i, val in enumerate(lst, start=1)])
    cand.append(tmp)
print(min(cand))
# Judge status: Accepted
import math
import copy

neko = 0
nuko = 0
inu = 0
n = int(input())
h = [int(x) for x in input().split()]
nya = h[0]
h = h[1:]
for i in h:
    if nya >= i:
        neko += 1
    else:
        neko = 0
    if neko > inu:
        inu = neko
    nya = i
print(inu)
# Judge status: Accepted
x, y, z = map(int, input().split())
c = (x - z)//(y+z)
print(c)
# Judge status: Accepted
q,h,s,d = map(int,input().split())
n = int(input())
a = 0
if n%2 == 1:
  n -= 1
  a += 1
ans = n//2*min(8*q,4*h,2*s,d)+a*min(4*q,2*h,s)
print(ans)
# Judge status: Wrong Answer
K=int(input())
print((K/2)**2 if K%2==0 else (K//2)*(K//2+1))
# Judge status: Accepted
s = input()

for i in range(97,123):
	if not chr(i) in s:
		print(chr(i))
		exit()

print("None")
# Judge status: Accepted
abc = sorted(list(map(int, input().split())))

ans = 0
if (abc[1]-abc[0])%2 == 1:
  ans += 1
  abc[1] += 1
  abc[2] += 1

ans += (abc[1]-abc[0])//2
abc[0] += abc[1]-abc[0]
ans += abc[2]-abc[1]
print(ans)
# Judge status: Wrong Answer
N = input()
count = 0
X = len(N) -1
for i in range(int(X/2)):
  if N[i] != N[-1]:
    count += 1
print(count)
# Judge status: Accepted
a,asp=map(int, input().split(" "))
b,bsp=map(int, input().split(" "))
t=(int)(input())
if asp > bsp:
  print("YES") if abs(b-a)/(asp-bsp) <= t else print("NO")
else:
  print("NO")
# Judge status: Wrong Answer
import math
x,y = map(int,input().split())
if x == 1:
    print(y-x+1)
else: 
    print(int(math.log2(y/x))+1)
# Judge status: Accepted
x,y ,z= map(int,input().split())
print((x-z)//(y+z))
# Judge status: Wrong Answer
S=input()
N=len(S)
M=N//2
def kaibun(x):
    n=len(x)
    m=n//2
    if x[:m]==x[m+1:][::-1]:
        return True
    else:
        return False
if all([kaibun(S),kaibun(S[:M])]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
D, N = map(int,input().split())
if D == 0:
    if N < 100:
        print(N)
    else:
        print(101)
elif D == 1:
    if N < 100:
        print(N*100)
    else:
        print(10100)
else:
    if N < 100:
        print(N*10000)
    else:
        print(1010000)
# Judge status: Wrong Answer
N = int(input())
s = [int(input()) for _ in range(N)]
s.sort()

while sum(s) % 10 == 0 and len(s) != 0:
    s = s[1:]

print(sum(s))
# Judge status: Accepted
N = list(input())
print("2018/01/"+N[-2]+N[-1])
# Judge status: Accepted
# AGC112 D - Partition
from math import floor
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


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

n_max=floor(m/n)
div_m=divisor(m)
div_m.sort(reverse=True)
ans=0
for i in div_m:
    if i<=n_max:
        print(i)
        exit()
# Judge status: Accepted
A, B, C = map(int, input().split())
cnt = 0
while A % 2 == B % 2 == C % 2 == 0:
    # print(A, B, C)
    if A == B == C:
        print(-1)
        break
    A, B, C = (B+C)//2, (C+A)//2, (A+B)//2
    cnt += 1
else:
    print(cnt)
# Judge status: Accepted
#A
a,b = map(int,input().split())
cnt = 0
if a > b:
    cnt += a
    a -= 1
else:
    cnt += b
    b -= 1
   
if a > b:
    cnt += a
    a -= 1
else:
    cnt += b
    b -= 1
    
print(cnt)
# 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())
A, B, C = [list(map(int, input().split())) for i in range(3)]

S = 0

for i in range(N):
    S += B[i]
    try:
        if A[i+1] == A[i]+1:
            S += C[A[i]-1]
    except IndexError as e:
        continue

print(S)
# Judge status: Accepted
import sys

def solve():
    input = sys.stdin.readline
    X, Y = map(int, input().split())
    length = 0
    now = X
    while now <= Y:
        now *= 2
        length += 1
    print(length)

    return 0

if __name__ == "__main__":
    solve()
# Judge status: Wrong Answer
# coding: utf-8 
#Author:Code

a = input()
b = input()
c = input()
d = input()
e = input()
k = input()
if k > e - a:
    print "Yay!"
else:
    print ":("
# Judge status: Wrong Answer
import sys
s = list(set(input()))
s.sort()
alp = list('abcdefghijklmnopqrstuvwxyz')

count = 0
for s_,alp_ in zip(s,alp):
    if s_ != alp_ :
        print(alp_)
        sys.exit()
    count += 1

print('None' if count == 24 else alp[count])
# Judge status: Accepted
def resolve():
    N, K = list(map(int, input().split()))
    S = list(input())
    base = 0
    prev = S[0]
    for i in range(1, N):
        if prev == S[i]:
            base += 1
        prev = S[i]
    
    print(min(base+2*K, N-1))


if '__main__' == __name__:
    resolve()