public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String str = sc.next();
            int n = sc.nextInt();
            //子串集合
            StringBuilder sb = new StringBuilder(str);
            List<String> list = new ArrayList<>();
            for (int i = 0; (i + n -1) < str.length(); i++) {
                list.add(sb.substring(i,i + n));
            }
            getResult(list);
        }
    }

    private static void getResult(List<String> list) {
        Map<String, Integer> map = new LinkedHashMap<>();
        for (int i = 0; i < list.size(); i++) {
            int CGcount = 0;
            String s = list.get(i);
            for (int j = 0; j < s.length(); j++) {
                if(s.charAt(j) == 'C' || s.charAt(j) == 'G'){
                    CGcount++;
                }
            }
            map.put(s, CGcount);
        }
        int max = 0;
        for (Integer value : map.values()) {
            max = Integer.max(value,max);
        }
        for (String s : map.keySet()) {
            if(map.get(s) == max){
                System.out.println(s);
                break;
            }
        }
    }
}