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

int main() {
    char s[1001] = {};
    int n,i,j;
    int length = 0;
    int max = 0;
    int maxp = 0;
    int temp = 0;

    while (scanf("%s\n%d", s, &n) != EOF) {
        length = strlen(s);
        for (i=0; i<length-n; ++i) {
            temp = 0;
            for (j=0; j<n; ++j) {
                if (s[i+j]=='G' || s[i+j]=='C') {
                    temp++;
                } else {}
            }
            if (temp > max) {
                max = temp;
                maxp = i;
            } else {}
        }
        for (i=0; i<n; ++i) {
            printf("%c", s[maxp+i]);
        }
        printf("\n");
    }
    return 0;
}