while True: try: s=str(input()) n=int(input()) i=0 c_max='' GCcount=0 index=0 while i+n<=len(s): if s[i:i+n].count('G')+s[i:i+n].count('C')> GCcount: index=i c_max=s[index:index+n] GCcount=c_max.count('G')+c_max.count('C') i+=1 print(c_max) except: break