s, N = input(), int(input())

# Algo
cnt = sum(s[i] == 'C' or s[i] == 'G' for i in range(N))  # Init
resEndI, maxCnt = N-1, cnt
for i in range(N, len(s)):
    chDel, chAdd = s[i-N], s[i]
    if chDel == 'C' or chDel == 'G': cnt -= 1
    if chAdd == 'C' or chAdd == 'G': cnt += 1
    if cnt > maxCnt:
        maxCnt = cnt
        resEndI = i

# Output
print(s[resEndI-N+1:resEndI+1])