import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // DNA序列,找出GC比例最高的子串,如果有多个则输出第一个的子串
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            StringBuffer bf = new StringBuffer(sc.nextLine());
            int target = sc.nextInt();

            Map<String, Double> map = new LinkedHashMap<>(); // LinkedHashMap底层基于链表,能够保证插入的顺序,和HashMap不同点
            for(int i = 0; i <= bf.length() - target;i++){
                double CorG = 0;
                int k = i;
                for(int j = 1;j <= target;j++,k++){
                    // 遍历得到的数组
                    if(bf.charAt(k) == 'C' || bf.charAt(k) == 'G') CorG++;
                }
                map.put(bf.substring(i,i + target),CorG/target);
            }
            // 记录结果的两个变量
            String res = null;
            double weight = -1;// 权重
//            System.out.println(map);
            for (String key: map.keySet()){
                if(map.get(key) > weight){
                    res = key;
                    weight = map.get(key);
                }
            }
            System.out.println(res);
        }
    }
}