import java.util.*;

/**
 * 输入描述:
 * 输入一个string型基因序列,和int型子串的长度
 * <p>
 * 输出描述:
 * 找出GC比例最高的子串,如果有多个则输出第一个的子串
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            String str = in.nextLine();
            int l = Integer.parseInt(in.nextLine()); // 子串长度
            String top = ""; // gc最高的子串
            int topGCNum = 0; // 最高的gc次数
            for (int i = 0; i <= str.length() - l; i++) {
                String s = str.substring(i, i + l);
                final char[] chars = s.toCharArray();
                int tmpGCNum = 0;
                for (char ch : chars) {
                    if (ch == 'G' || ch == 'C') {
                        tmpGCNum++;
                    }
                }
                // 每次和最高gc次数比较,找到最高的gc次数
                if (tmpGCNum > topGCNum) {
                    top = s;
                    topGCNum = tmpGCNum;
                }
            }
            System.out.println(top);
        }
    }

}