# 子串是连续的,按照n为长度截取
while True:
    try:
        s = input()
        ls = len(s)
        n = int(input())
        zc = [] #存储截取到的子串
        # 生成zc
        for i in range(ls - 1):    # (ls -2) + 1
            if i + n < ls:
                zc.append(s[i:i + n])
            else:
                zc.append(s[i:])
        # print(zc)  # AC CG GT
        rad = []  # 存储计算GC_Ratio
        # 计算GC_Ratio
        for i in zc:
            g_cnt = i.count('G')
            c_cnt = i.count('C')
            rad.append((g_cnt + c_cnt) / ls)
        # print(rad)  # [0.25, 0.5, 0.25]
        max_rad = max(rad)
        max_index = rad.index(max_rad)
        print(zc[max_index])
    except:
        break