gene , l , rate = input() , int(input()) , [] for i in range(len(gene)): rate.append(gene[i:min(i+l,len(gene))].count('C')+gene[i:min(i+l,len(gene))].count('G')) print(gene[rate.index(max(rate)):rate.index(max(rate))+l]) #相对会耗时但很简短能过