let input;
let time = 1;
let str;
while (input = readline()) {
    if (time === 1) {
        str = input;
    }
    if (time === 2) {
        const N = parseInt(input);
        let index = 0;
        let max = 0;
        for(let i = 0; i <= str.length - N; i++) {
            let tmp = str.slice(i, N+i).split('');
            let count = 0;
            for(let j = 0; j < tmp.length; j++) {
                if (tmp[j] === 'G' || tmp[j] === 'C') {
                    count++;
                }
            }
            if(count > max) {
                max = count;
                index = i;
            }
        }
        
        print(str.slice(index, index + N));
        
        time = 0;
    }

    time++;
}