a = input().strip()
n = int(input())
l = []
m = []
for i in range(len(a)):
    s = a[i:i+n].count('G') + a[i:i+n].count('C')
    l.append(a[i:i+n])
    m.append(s/n)
x = max(m)
print(l[m.index(x)])