import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
scanner.useDelimiter("\n");
while (scanner.hasNext()) {
String S = scanner.next();
int N = scanner.nextInt();
int max = N;
boolean A= false;
while (max>0) {
int left = 0;
int right = N+left-1;
while (right<S.length()) {
String substring = S.substring(left, right + 1);
if (substring.length() - substring.replaceAll("[G_C]", "").length() == max) {
System.out.println(substring);
A = true;
break;
}
left++;
right++;
}
if (A) {
break;
}
max--;
}
}
}
}