while True:
try:
str_input = input()
n = int(input())
gc_ratio_list = [0] * (len(str_input) - n + 1)
for i in range(len(gc_ratio_list)):
g_count = str_input[i: i + n].count('G')
c_count = str_input[i: i + n].count('C')
gc_ratio_list[i] = (g_count + c_count) / len(str_input)
print(str_input[gc_ratio_list.index(max(gc_ratio_list)): gc_ratio_list.index(max(gc_ratio_list)) + n])
except:
break