# Process input
s = input()
n = int(input())

# Special cases
if len(s) < n:
    exit()

# Init
resEnd = n - 1
cntCG = 0
for i in range(n):
    ch = s[i]
    if ch == 'C' or ch == 'G':
        cntCG += 1
maxRatio = cntCG / n

# Detect
for i in range(n, len(s)):
    chDel = s[i-n]
    chAdd = s[i]
    if chDel == 'C' or chDel == 'G':
        cntCG -= 1
    if chAdd == 'C' or chAdd == 'G':
        cntCG += 1
    ratio = cntCG / n
    if ratio > maxRatio:
        maxRatio = ratio
        resEnd = i

# Output
resEnd += 1
res = s[resEnd-n: resEnd]
print(res)