import java.util.Scanner;
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNext()) { // 注意 while 处理多个 case
String a = in.nextLine();
int b = in.nextInt();
System.out.println(findFirstDnaStr(a,b));
}
}
public static String findFirstDnaStr(String str, int num) {
if (str.length() <= num) {
return str;
}
Map<Double, String> map = new HashMap<>();
for (int i = 0; i < str.length() - num; i++) {
String subStr = str.substring(i, i + num);
double gc = 0;
for (char c : subStr.toCharArray()) {
if (c == 'G' || c == 'C') {
gc++;
}
}
double gcRatio = gc / num;
if (!map.containsKey(gcRatio)) {
map.put(gcRatio, subStr);
}
}
return map.get(map.keySet().stream().max(Double::compare).get());
}
}