#include <stdio.h>
#include <string.h>

int main()
{
    char str[1000], ans[1000];
    int num, max = 0;
    while(scanf("%s", str) != EOF)
    {
        scanf("%d", &num);
        int len = strlen(str);
        for(int i = 0; i < len-num+1; i++)
        {
            int n = 0;
            int j;
            for(j = i; j < i+num; j++)
            {
                if(str[j] == 'C' || str[j] == 'G')
                {
                    n++;
                }
            }
            if(max < n)
            {
                max = n;
                strcpy(ans, str+i);
                ans[num] = '\0';
            }
        }
        printf("%s", ans);
    }
    return 0;
}