def maxGCR(dna, n):
    gcrs = [0.0] * (len(dna) - n + 1)
    for i in range(len(dna) - n + 1):
        gcrs[i] = (dna[i:i+n].count('G') + dna[i:i+n].count('C'))/n
    maxIndex = gcrs.index(max(gcrs))
    return dna[maxIndex: maxIndex + n]
while 1:
    try:
        dna, n = input().upper(), int(input())
        print(maxGCR(dna, n))
    except:
        break