while True: try: s = input() zclen = int(input()) slen = len(s) GCR = 0 result = [0,'']
for i in range(slen):
teststr = s[i:zclen+i]
GCR = teststr.count('G')+teststr.count('C')
if len(teststr) == zclen and result[0] < GCR:
result[0] = GCR
result[1] = teststr
print(result[1])
except:
break