Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
from IPython import embed
H, W = [int(s) for s in input().split(" ")]

maze = [list(input()) for _ in range(H)]

distance = [[float("inf") for i in range(W)] for j in range(H)]

def bfs():
    queue = []
    sx = 0
    sy = 0
    gx = H-1
    gy = W-1

    queue.insert(0, (sx, sy))

    distance[sx][sy] = 0

    while len(queue):
        x, y = queue.pop()

        if x == gx and y == gy:
            break

        for i in range(0, 4):
            nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
            
            if (0 <= nx < H and 0 <= ny < W):
                if maze[nx][ny] != '#' and distance[nx][ny] == float("inf"):
                    queue.insert(0, (nx, ny))
                    distance[nx][ny] = distance[x][y] + 1

    return distance[gx][gy]

d = bfs()
cnt = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == ".":
            cnt += 1
if  d == float("inf"):
    print(-1)
else:
    print(cnt - d - 1)


### FIXED CODE ###

# -*- coding: utf-8 -*-
H, W = [int(s) for s in input().split(" ")]

maze = [list(input()) for _ in range(H)]

distance = [[float("inf") for i in range(W)] for j in range(H)]

def bfs():
    queue = []
    sx = 0
    sy = 0
    gx = H-1
    gy = W-1

    queue.insert(0, (sx, sy))

    distance[sx][sy] = 0

    while len(queue):
        x, y = queue.pop()

        if x == gx and y == gy:
            break

        for i in range(0, 4):
            nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
            
            if (0 <= nx < H and 0 <= ny < W):
                if maze[nx][ny] != '#' and distance[nx][ny] == float("inf"):
                    queue.insert(0, (nx, ny))
                    distance[nx][ny] = distance[x][y] + 1

    return distance[gx][gy]

d = bfs()
cnt = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == ".":
            cnt += 1
if  d == float("inf"):
    print(-1)
else:
    print(cnt - d - 1)
import sys
print(1 + min(sys.argv[1] + sys.argv[2], sys.argv[3] - 1) + sys.argv[2])

### FIXED CODE ###

import sys
a, b, c = (int(i) for i in input().split())  
print(1 + min(a + b, c - 1) + b)
import math
a=input()
a1=list(a)
b=a1[:]
b.sort()
b="".join(b)
c=set(a1)
d=[]
for i in c:
    for i1 in range(math.floor(len(a1)/2),len(a1)+1):
        d.append(i*i1)
for i in d:
    if i in b:
        print("{}".format(a.find("{}".format(i[0]))+1)+" "+"{}".format(a.rfind("{}".format(i[0]))+1))
        break
else:
    print("-1 -1")

### FIXED CODE ###

a=input()
if len(a)==1:
    print("-1 -1")
elif (len(a)==2)&(len(list(set(a)))==1):
    print("1 2")
else:
    for i in range(len(a)-2):
        e=list(set(a[i:i+3]))
        if (len(e)==2) or (len(e)==1):
            print("{}".format(i+1)+" "+"{}".format(i+3))
            break
    else:
        print("-1 -1")
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())))[::-1]
B=sorted(list(map(int,input().split())))[::-1]
C=sorted(list(map(int,input().split())))[::-1]
ans=[0]*(len(A)*len(B)*len(C))
ind=0
for a in range(len(A)):
  for b in range(len(B)):
    for c in range(len(C)):
      if (a+1)*(b+1)*(c+1)>K:
        break
      ans[ind]=A[a]+B[b]+C[c]
      ind+=1

ans=sorted(ans)[::-1]
for i in range(K):
  print(ans[i])

### FIXED CODE ###

X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())))[::-1]
B=sorted(list(map(int,input().split())))[::-1]
C=sorted(list(map(int,input().split())))[::-1]
ans=[]
for a in range(len(A)):
  for b in range(len(B)):
    for c in range(len(C)):
      if (a+1)*(b+1)*(c+1)>K:
        break
      ans.append(A[a]+B[b]+C[c])

ans=sorted(ans)[::-1]
for i in range(min(K,len(ans))):
  print(ans[i])
N=int(input());print(~-N*N//2)

### FIXED CODE ###

#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    s=input()
    t=input()
    ans=0
    for i in range(3):
        if s[i]==t[i]:
            ans+=1
    print(ans)
    
    
    
    
if __name__ == '__main__':
    main()
z,v,a=input,range,print
h,w,k=map(int,z().split())
r,s,t,u=map(lambda x:int(x)-1,z().split())
b=[z()for _ in v(h)]
l=[[-1]*w for _ in v(h)]
l[r][s]=0
from collections import*
d=deque([(r,s)])
while d:
  x,y=d.popleft()
  if(x==t)&(y==u):exit(a(l[x][y]))
  for e,f in[[1,0],[-1,0],[0,-1],[0,1]]:
    for i in v(1,k+1):
      if not((0<=p:=(x+e*i)<h)&(0<=q:=(y+f*i)<w))or b[p][q]=="@" or 0<=l[p][q]<=l[x][y]:break
      if l[p][q]==-1:d+=[(p,q)];l[p][q]=l[x][y]+1
a(-1)

### FIXED CODE ###

import sys
inf=1000002
sys.setrecursionlimit(inf)
from collections import deque
h,w,k=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
c=[input() for i in range(h)]
dp=[[inf if c[i][j]=="." else -1 for j in range(w)] for i in range(h)]
now=deque()
now.append([x1-1,y1-1])
dp[x1-1][y1-1]=0
#kの更新が遅い
def bfs(d):
    global h,w,k,dp,now,x2,y2
    l=len(now)
    if l==0:
        return
    dp_sub=deque()
    cand=set()
    for i in range(l):
        x,y=now.popleft()
        for j in range(1,min(k+1,w-y)):
            if dp[x][y+j]==inf:
                dp_sub.append([x,y+j,d])
                #dp[x][y+j]=d
                cand.add((x,y+j))
                #now.append([x,y+j])
            else:
                break
        for j in range(1,min(k+1,y+1)):
            if dp[x][y-j]==inf:
                dp_sub.append([x,y-j,d])
                #dp[x][y-j]=d
                cand.add((x,y-j))
                #now.append([x,y-j])
            else:
                break
        for j in range(1,min(k+1,h-x)):
            if dp[x+j][y]==inf:
                dp_sub.append([x+j,y,d])
                #dp[x+j][y]=d
                cand.add((x+j,y))
                #now.append([x+j,y])
            else:
                break
        for j in range(1,min(k+1,x+1)):
            if dp[x-j][y]==inf:
                dp_sub.append([x-j,y,d])
                #dp[x-j][y]=d
                cand.add((x-j,y))
                #now.append([x-j,y])
            else:
                break
    while dp_sub!=deque([]):
        e=dp_sub.popleft()
        dp[e[0]][e[1]]=e[2]
    for i in cand:
        now.append(i)
    bfs(d+1)
bfs(1)
print(dp[x2-1][y2-1] if dp[x2-1][y2-1]!=inf else -1)
import copy

n,m=map(int, input().split())
p=list(map(int, input().split()))
q=list()
for i in range(m):
    q.append(set(map(int, input().split())))
count=0
while count!=5000:
    a=q.pop()
    for j in q:
        if len(j&a) != 0:
            j |=a
            count=0
            break
    else:q=[a]+q
    if count>len(q): break
    count+=1

q2=copy.copy(set(p))
for i in q:
    q2 -= i
    
count2=len([i for i in q2 if i==p[i-1]])

for i in q:
    r=list()
    for j in list(i):
        r.append(p[j-1])
    #print(i,r)
    count2 += len(i&set(r))
print(count2)

### FIXED CODE ###

s=input()
k=int(input())
s1=list(s)
s2=[s[i:i+2] for i in range(len(s)-1)]
s3=[s[i:i+3] for i in range(len(s)-2)]
s4=[s[i:i+4] for i in range(len(s)-3)]
s5=[s[i:i+5] for i in range(len(s)-4)]
sall=sorted(list(set(s1+s2+s3+s4+s5)))
print(sall[k-1])
s=input()

le=0
i=0
while(i<len(s)):
    l=0
    while(s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T'):
        l+=1
        i+=1

    if(l>le):
        le=l
    l=0
    i+=1
print(le)

### FIXED CODE ###

s=input()

le=0

i=0
while(i<len(s)):
    l=0
    while(i<len(s) and (s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T')):
        l+=1
        i+=1

    if(l>le):
        le=l
    l=0
    i+=1
print(le)
a,b = input().split()

a_ = a * int(a)
b_ = b * int(b)

moji = sorted([a_ ,b_])

print(mojj[0])

### FIXED CODE ###

a,b = input().split()
 
a_ = a * int(b)
b_ = b * int(a)
 
moji = sorted([a_ ,b_])
 
print(moji[0])
t = input()
for i in range(len(t)):
    if t[i] == '?':
        t[i] = 'D'
print(ans)

### FIXED CODE ###

print(input().replace('?','D'))
from mpmath import *

mp.dps=50
mp.pretty = True

a,b,c = (int(x) for x in input().split())
if a+b+2*(mp.sqrt(a*b)) < c:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

from decimal import *
a,b,c = (int(x) for x in input().split())
a = Decimal(a)
b = Decimal(b)
c = Decimal(c) 
if a+b+2*(a.sqrt()*b.sqrt()) < c:
    print('Yes')
else:
    print('No')
n = list(input().split())
if n[0]==n[2]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = list(input())
if n[0]==n[2]:
    print("Yes")
else:
    print("No")
N, T = map(int, input().split())
a = []
for i in range(N):
    a.append(list(map(int, input().split())))

b = []

for i in range(N):
    if a[i][1] <= T:
        b.append(a[i][0])

print(min(b))


### FIXED CODE ###

N, T = map(int, input().split())
a = []
for i in range(N):
    a.append(list(map(int, input().split())))

b = []
count = 0
for i in range(N):
    if a[i][1] <= T:
        b.append(a[i][0])
        count += 1
if count == 0:
    print('TLE')

else:
    print(min(b))
s=list(input())
while(1):
    if len(s)==1:
        print(s)
        break
    s.pop(-1)
    if s[:t]==s[t:]:
        print(len(s))
        break
    t=int(len(s)/2)

### FIXED CODE ###

s=list(input())
while(1):
    t=int(len(s)/2)
    if len(s)==1:
        print(s)
        break
    s.pop(-1)
    if s[:t]==s[t:]:
        print(len(s))
        break
from fractions import gcd 

l = list(map(int,input().split()))
A = l[0]
B = l[1]
C = l[2]
D = l[3]

E = C * D //math.gcd(C,D)

f = B//C - (A-1)//C
f = f+(B//D - (A-1)//D)
ans = B-A+1-f + B//E-(A-1)//E
print(ans)


### FIXED CODE ###

from fractions import gcd 

l = list(map(int,input().split()))
A = l[0]
B = l[1]
C = l[2]
D = l[3]

E = C * D //gcd(C,D)

f = B//C - (A-1)//C
f = f+(B//D - (A-1)//D)
ans = B-A+1-f + B//E-(A-1)//E
print(ans)
S = str(input())
Slist = list(S)
newlist = list(reversed(Slist))
ans != 0
for i in range((len(S)//2)):
  if Slist[i] == newlist[i]:
    ans += 1
    
print(ans)

### FIXED CODE ###

S = str(input())
Slist = list(S)
newlist = list(reversed(Slist))
ans = 0
for i in range((len(S)//2)):
  if Slist[i] != newlist[i]:
    ans += 1
    
print(ans)
a,b,c,d = map(int,input().split())
A = (a*c)
B = (a*d)  
C = (b*c)
D = (c*d)
MAX = A

if MAX < B:
    MAX = B
elif MAX < C:
    MAX = C
elif MAX < D:
    MAX = D

print(MAX)

### FIXED CODE ###

a = int(input())
if a == 0:
    print('1')
else:
    print('0')
import itertools
L,R = map(int,input().split())

ans_list=[]
for v in itertools.combinations(range(L,R+1),2):
  ans_list.append((v[0]*v[1])%2019)
print(min(ans_list))

### FIXED CODE ###

import itertools
L,R = map(int,input().split())
if (L+2019) < R:
  R = L+2019

ans_list=[]
for v in itertools.combinations(range(L,R+1),2):
  buf1 = v[0]%2019
  buf2 = v[1]%2019
  ans_list.append((buf1*buf2)%2019)
print(min(ans_list))
nk = list(map(int,input().split()))
li = list(map(int,input().split()))
n,k = nk[0], nk[1] #5,3
DP = [0]
for i in range(1, n):#0~3 -> 1~4
  act = float("inf")
  for k_ in range(1, k+1):#0~2 -> 1~3
    if i-k_ < 0 : continue
    act = min(DP[-k_] + abs(h[i-k_]-h[i]), act)#
  DP+= [act]#[0,20,]
print(DP[-1])

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
 
DP = [0]
for i in range(N-1):
    act = float("inf")
    for k in range(K):
        if i-k < 0 : continue
        act = min(DP[-1-k] + abs(h[i-k]-h[i+1]) , act)
    DP += [act]
 
print(DP[-1])
n = input()
A = [int(i) for i in input().split(' ')]

def trace(A):
    for index, v in enumerate(A):
        print(v, end='')
        if index != len(A) - 1:
            print(' ', end='')
    print()

def bubble_sort(A, n):
    i = n - 1
    counter = 0
    while i >= 1:
        j = i - 1
        while j >= 0:
            if A[i] < A[j]:
                A[i], A[j] = A[j], A[i]
                counter += 1
            j -= 1
        i -= 1
    trace(A)
    print(counter)

bubble_sort(A, n)

### FIXED CODE ###

n = int(input())
A = [int(i) for i in input().split(' ')]
# A = '0 33 43 62 29 0 8 52 56 56 19 11 51 43 5 8 93 30 66 69'.split(' ')
# A = [int(i) for i in A]

def trace(A):
    for index, v in enumerate(A):
        print(v, end='')
        if index != len(A) - 1:
            print(' ', end='')
    print()

def bubble_sort(A, n):
    i = 0
    counter = 0
    while i <= n - 1:
        j = n - 1
        while j >= i + 1:
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                counter += 1
            j -= 1
        i += 1
    trace(A)
    print(counter)

bubble_sort(A, n)
n = int(input())
i = n % 2

if i == 0:
  print(n)
else
  print(n*2)

### FIXED CODE ###

n = int(input())
i = n % 2
 
if i == 0:
  print(n)
else:
  print(n*2)
A, B = map(int, input().split())
 print(A-2*B) if A > 2*B else print(0)

### FIXED CODE ###

def main():
 A, B = map(int, input().split())
 print(A-2*B) if A > 2*B else print(0)
  
main()
def gcd(a,b):
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)

n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(set(a))
b=[x//2 for x in a]
b.sort(reverse=1)
v,w=b[0],b[1]
l=v*w//gcd(v,w)
for x in b:
  if l%x!=0:
    l=l*x//gcd(l,x)
ans=((m//l)+1)//2

print(ans)

### FIXED CODE ###

def gcd(a,b):
    if a % b == 0:
        return b
    else:
        return gcd(b,a%b)

n,m = map(int,input().split())
a = list(map(int,input().split()))
a = [a[i]//2 for i in range(n)]
l = 1
b = -1
for x in a:
    if l % x != 0:
        l = l * x // gcd(l,x)
    c = 0
    while x % 2 == 0:
        x = x // 2
        c += 1
    if b != -1 and b != c:
        print(0)
        exit()
    elif b == -1:
        b = c
        
ans = m // l
ans = (ans + 1) // 2
print(ans)
#print(l)
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)

#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了

cumsum(リスト) #累積和をリストで返す
cumsum_number(N,K,x) #N個の数が含まれるリストx内のK個からなる部分和をリストで返す
"""
S=list(input())
SS=S[0:(len(S)-1)//2]
SSS=S[(len(S)+3)//2:-1]
Sreverse=S[::-1]
if S==S[::-1] and SS==SS[::-1] and SSS==SSS[::-1]:
        print("Yes")
else:
    print("No")



### FIXED CODE ###

import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)

#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了

cumsum(リスト) #累積和をリストで返す
cumsum_number(N,K,x) #N個の数が含まれるリストx内のK個からなる部分和をリストで返す
"""
S=list(input())
SS=S[0:(len(S)-1)//2]
SSS=S[(len(S)+3)//2:-1]
Sreverse=S[::-1]
if S==S[::-1] and SS==SS[::-1] and SSS==SSS[::-1]:
        print("Yes")
else:
    print("No")
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

dif = []
for i in range(M-1):
    dif.append(A[i+1] - A[i])

for i in range(N-1):
    dif.remove(max(dif))

print(sum(dif))

### FIXED CODE ###

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

dif = []
for i in range(M-1):
    dif.append(A[i+1] - A[i])

dif.sort(reverse=True)
dif = dif[N-1:]

print(sum(dif))
a, b, c = (int, raw_input().split())
 
if a == b or a == c:
  print ('Yes')
elif b == c:
  print ('Yes')
else:
  print ('No')

### FIXED CODE ###

a, b, c = map(int, input().split())
 
if (a == b and c != a) or (a == c and b != a):
  print ('Yes')
elif b == c and a != b:
  print ('Yes')
else:
  print ('No')
n=int(input())
b=[int(x) for x in input().split()]
a=[0]*n
for i in range(n-1):
	if(i==0):
		a[0]=b[0]
		a[1]=b[1]
	elif(b[i]>=b[i-1]):
		a[i+1]=b[i]
	elif(b[i]<b[i-1]):		
		a[i]=b[i]
		a[i+1]=b[i]
print(sum(a))

### FIXED CODE ###

n=int(input())
b=[int(x) for x in input().split()]
a=[0]*n
for i in range(n-1):
	if(i==0):
		a[0]=b[0]
		a[1]=b[0]
	else:	
		if(b[i]>=b[i-1]):
			a[i+1]=b[i]
		if(b[i]<b[i-1]):		
			a[i]=b[i]
			a[i+1]=b[i]
print(sum(a))
a,b=map(int,input().split())
c=[1,2,3]
c.remove(a)
c.remove(b)
print(c[0])

### FIXED CODE ###

a,b=[int(input()) for i in range(0,2)]
c=[1,2,3]
c.remove(a)
c.remove(b)
print((c[0]))
inf = pow(10, 9)+7

def nCr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result *= numerator[k]
    return int(result)


n, k = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()

ans = 0
key = nCr(n-1, k-1)
for i in range(n-k+1):
    ans += ((a[-i-1] - a[i]))*(key)
    ans %= inf
    if n-i-1 != 0:
	    key = int(key*(n-k-i)/(n-1-i))
    else:
        break
print(ans)

### FIXED CODE ###

inf = pow(10, 9)+7

n, k = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()

ans = 0
comb = 1
for i in range(k, n+1):
    ans += (a[i-1]-a[-i])*comb
    ans %= inf
    comb = (comb * i * pow(i-k+1, inf-2, inf))%inf
print(ans)
num_str = input().split(" ")
S = input()

N = int(num_str[0])
K = int(num_str[1])

if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
elif S[K-1] == "C":
  S[K-1] = "c"
  
print(S)

### FIXED CODE ###

num_str = input().split(" ")
S = input()

N = int(num_str[0])
K = int(num_str[1])
s = list(S)

if s[K-1] == "A":
  s[K-1] = "a"
elif s[K-1] == "B":
  s[K-1] = "b"
elif s[K-1] == "C":
  s[K-1] = "c"

S = "".join(s)
print(S)
from collections import Counter
N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
xy = sorted(xy, key=lambda x: x[0])
counter = Counter()
for i in range(1, N):
    nxy = xy[i]
    pxy = xy[i-1]
    counter[(nxy[0]-pxy[0], nxy[1]-pxy[1])] += 1

print(N-counter.most_common(1)[0][1])


### FIXED CODE ###

from collections import Counter
N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
# xy = sorted(xy, key=lambda x: x[0])
counter = Counter()
for i in range(N):
    for j in range(i+1, N):
        nxy = xy[i]
        pxy = xy[j]
        counter[(nxy[0]-pxy[0], nxy[1]-pxy[1])] += 1
        counter[(pxy[0]-nxy[0], pxy[1]-nxy[1])] += 1
# print(counter)
if N == 1:
    print(1)
else:
    print(N-counter.most_common(1)[0][1])
hwsss = [s.rstrip() for s in open(0)]
H,W = map(int, hwsss[0].split())
sss = [[int(c=='#') for c in list(l)] for l in hwsss[1:]]

from functools import lru_cache
dhw = [
    [0,1],
    [0,-1],
    [1,0],
    [-1,0],
]
passed = set()

@lru_cache(maxsize=None)
def calc(h,w):
    passed.add((h,w))
    if h == H-1 and w == W-1:
        return 1
    ans = float('inf')
    for dh, dw in dhw:
        nh, nw = h+dh, w+dw
        if 0<=nh<H and 0<=nw<W and sss[nh][nw]==0 and ((nh,nw) not in passed or dh+dw>0):
            ans = min(ans, calc(nh,nw) + 1)
    return ans

print(H * W - sum(map(sum, sss)) - calc(0,0))

### FIXED CODE ###

from collections import defaultdict, deque
hwsss = [s.rstrip() for s in open(0)]
H,W = map(int, hwsss[0].split())
sss = [[int(c=='#') for c in list(l)] for l in hwsss[1:]]

dhw = [
    [0, 1],
    [1, 0],
    [0, -1],
    [-1, 0],
]

# h,w,dist
dq = deque([(0, 0, 0)])
# h,w
queued = {(0, 0)}

fdist = -1
while dq:
    h, w, dist = dq.popleft()
    
    if h == H - 1 and w == W - 1:
        fdist = dist
        break
        
    for dh, dw in dhw:
        nh = h + dh
        nw = w + dw
        ndist = dist + 1

        if (nh,nw) in queued:
            continue
        if not(0 <= nh < H) or not(0 <= nw < W):
            continue
        if sss[nh][nw]:
            continue

        dq.append((nh, nw, ndist))
        queued.add((nh, nw))

if fdist == -1:
    print(-1)
else:
    print(H * W - sum(sum(sss,[])) - fdist - 1)
def calc( s , k , n):

	bruh = {}
	for i  in range(1, n + 1): # length
		for j in range( n - ( i - 1)): # start 
			bruh[s[j: j + i:]] = 0
	another = bruh.keys()
	another = sorted(another)
	return another[k - 1]

s = raw_input()

k = int(raw_input())

n = len(s)
 
print( calc( s , k , n))

### FIXED CODE ###

def calc( s , k , n):

	bruh = {}
	for i  in range(1, k + 1): # length
		for j in range( n - ( i - 1)): # start 
			bruh[s[j: j + i:]] = 0
	another = bruh.keys()
	another = sorted(another)
	print( another[k - 1])

s = input()

k = int(input())

n = len(s)
 
calc( s , k , n)
n=int(input())
li=list(map(int,input().split()))
li.sort()
print(li[n/2]-li[n/2-1])

### FIXED CODE ###

n=int(input())
li=list(map(int,input().split()))
li.sort()
print(li[n//2]-li[n//2-1])
a,b,c,d = map(int,raw_input().split())
if abs(a-b)<=d:
        if abs(b-c)<=d:
                print'Yes'
else:
        print'No'

### FIXED CODE ###

a,b,c,d = map(int,input().split())
if abs(a-b)<=d:
        if abs(b-c)<=d:
                print("Yes")
        else:
                print("No")
elif abs(a-c)<=d:
        print("Yes")
else:
        print("No")
a,b,c,d=map((int,input().split()))
start=min(a,b)
end=min(c,d)
print(end-start if end-start > 0 else 0)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
start=max(a,c)
end=min(b,d)
print(end-start if end-start > 0 else 0)
h, w = map(int, input().split())
s = ['.'*(h+2)]
for i in range(h):
  ss = '.' + input() + '.'
  s.append(ss)
s.append('.'*(h+2))
dx = [1,0,-1,0]
dy = [0,1,0,-1]
for i in range(h):
  for j in range(w):
    cnt = 0
    for k in range(4):
      xi = i + dx[k]
      yi = j + dy[k]
      if s[i][j] == '#' and s[xi][yi] == '.':
        cnt += 1
    if cnt == 4:
      print('No')
      exit()

print('Yes')


### FIXED CODE ###

h, w = map(int, input().split())
s = ['.'*(w+2)]
for i in range(h):
  ss = '.' + input() + '.'
  s.append(ss)
s.append('.'*(w+2))
dx = [1,0,-1,0]
dy = [0,1,0,-1]
for i in range(h):
  for j in range(w):
    cnt = 0
    for k in range(4):
      yi = i + dy[k]
      xi = j + dx[k]
      if s[i][j] == '#' and s[yi][xi] == '.':
        cnt += 1
    if cnt == 4:
      print('No')
      exit()

print('Yes')