dna = str(input())
n = int(input())
res = ""
ratio = 0

for i in range(len(dna)-n+1):
    temp = dna[i:i+n]#!注意用切片的思想!!!
    temp_r = temp.count("G") + temp.count("C")
    if temp_r > ratio:
        res = temp
        ratio = temp_r

print(res)