const str=readline();
const num=parseInt(readline());
getDna(str,num)

function getDna(x,y){
    let a=0;
    let res;
//     计算子串的个数,并分割子串,计算比较子串是否符合条件
    const len=x.length-y;
    for(let i=0;i<=len;i++){
        let re=x.slice(i,i+y);       
        let n=0;
        for(let j=0;j<y;j++){
            if(re[j]==='G'||re[j]==='C'){
                n++
            }
        }
        let b = n/y
        if(b>a){
            a = b
            res=re           
        }    
    }
    console.log(res)
}