import java.util.Scanner;
/**
* HJ63 DNA序列 -中等
*/
public class HJ063 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String str = sc.next();
int num = sc.nextInt();
String CGRate = getCGRate1(str, num);
System.out.println(CGRate);
}
sc.close();
}
public static String getCGRate1(String str, int num) {
int max = 0;
int subBegin = 0;
for (int i = 0; i <= str.length() - num; i++) {
int cgCount = 0;
// 遍历统计CG个数
for (int j = 0; j < num; j++) {
if (str.charAt(i + j) == 'C'
|| str.charAt(i + j) == 'G') {
cgCount++;
}
}
// CG个数大于历史最高,记录截取开始位置
if (cgCount > max) {
max = cgCount;
subBegin = i;
}
}
String CGRate = str.substring(subBegin, subBegin + num);
return CGRate;
}
}