while True:
    try:
        myStr = input()
        N=int(input())
        AllSunStr=[]
        Rlist=[]
        mydic={}
        for i in range(len(myStr)-N+1):
            AllSunStr.append(myStr[i:i+N]) # 所有长度为N的子串
        for j in AllSunStr:
            num=0
            for x in j:
                if x == 'C'&nbs***bsp;x=='G':
                    num+=1
            Rlist.append(num/N)
            mydic[j]=num/N
        Rmax = sorted(Rlist,reverse=True)[0]
        for e in AllSunStr:
            if mydic[e]==Rmax:
                print(e)
                break
    except:
        break