# append到一個list 用for 去對數字 然後如果開始!= k 就print(i) break # 1 -> 1 2 4 -> 2 # 3 -> 23222 -> 3 # 2 -> 3225 -> 8 def count(string): list1 = [] #紀錄幾個 countbig = 0 countsmall = 0 for i in range(len(string)): #print(countbig, countsmall) if string[i].isupper(): if countbig == 0 and countsmall != 0: list1.append(countsmall) countsmall = 0 countbig += 1 else: countbig += 1 else: if countsmall == 0 and countbig != 0: list1.append(countbig) countbig = 0 countsmall += 1 else: countsmall += 1 if countbig != 0: list1.append(countbig) elif countsmall != 0: list1.append(countsmall) return list1
#[1, 2, 4] k = int(input()) string = input() list1 = count(string) #print(list1) now = 0 long = 0 for i in list1: if i == k: now += k if now > long: long = now elif i > k: #now += k if now + k > long : long = now + k now = k elif i < k: now = 0 print(long)