#coding:utf-8 N,K=map(int,raw_input().split()) S=raw_input() cnt_l,ans_l=0,0 cnt_r,ans_r=0,0 if K <= len(S)/2: for i in S[K-1:]: cnt_l+=1 if i == S[K-1]: ans_l+=1 else: ans_l-=1 if ans_l == 0: print cnt_l+(K-1) break else: for i in S[:K][::-1]: cnt_r+=1 if i == S[K-1]: ans_r+=1 else: ans_r-=1 if ans_r == 0: print cnt_r-(K-1) break