import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String line = sc.nextLine();
int n = Integer.parseInt(sc.nextLine());
if (line.length() == n) {
System.out.println(line);
return;
}
int max = Integer.MIN_VALUE;
Map<String, Integer> map = new LinkedHashMap<>();
for (int i = 0; i < line.length() - n + 1; i++) {
String substring = line.substring(i, i + n);
int count = 0;
for (char c : substring.toCharArray()) {
if (c == 'C' || c == 'G') {
count++;
}
}
max = Math.max(max, count);
map.put(substring, count);
}
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == max) {
System.out.println(entry.getKey());
break;
}
}
}
sc.close();
}
}