#23877: jameslee


91xb30@ms.mingdao.edu.tw (X102 30黃冠穎)

學校 : 不指定學校
編號 : 129581
來源 : [114.42.92.10]
最後登入時間 :
2022-10-03 20:29:39
c462. apcs 交錯字串 (Alternating Strings) -- apcs | From: [140.128.156.248] | 發表日期 : 2020-12-29 15:07

t=int(input())
l=input()
c=[]
count=0
for i in range(len(l)):
  if i==0:
    count+=1
    continue
  if l[i].isupper():
    if l[i-1].isupper():
      count+=1
    else:
      c.append(count)
      count=1
  elif l[i].islower():
    if l[i-1].islower():
      count+=1
    else:
      c.append(count)
      count=1
c.append(count)
count=0
su=0
for i in range(len(c)):
  if c[i]>t:
    count+=1
    if su<count:
      su=count
    count=1
  elif c[i]==t:
    count+=1
  elif c[i]<t:
    count=0
  if su<count:
      su=count
print(su*t)
 
ZeroJudge Forum