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 next = in.next();
int i = in.nextInt();
LinkedHashMap<Integer, Double> map = new LinkedHashMap<>();
for (int j = 0,k = i; k < next.length(); j++,k++) {
String s = next.substring(j, k);
char[] chars = s.toCharArray();
double count = 0;
for (int z = 0; z < chars.length; z++) {
char c = chars[z];
if (c == 'G' || c == 'C'){
count++;
}
}
map.put(j,count/i);
}
Set<Map.Entry<Integer, Double>> entries = map.entrySet();
int index = getIndex(entries);
System.out.println(next.substring(index,index + i));
}
}
public static int getIndex(Set<Map.Entry<Integer, Double>> entries){
double max = 0;
int index = 0;
for (Map.Entry<Integer, Double> entry : entries) {
Double value = entry.getValue();
double v = Math.max(max, value);
if (v != max){
max = v;
index = entry.getKey();
}
}
return index;
}
}