#include <bits/stdc++.h>
using namespace::std;

int main()
{
    string str;
    int num;
    
    while (cin >> str >> num) {
        string s;
        string subs; //保存最大值对应的字串
        int max = 0; // 最大值
        for (int i = 0;i < str.size();i++) {
            int cnt = 0; // 记录当前长度
            s = str.substr(i, num); // 子串
            for (auto const &c : s) {
                if (('C' == c) || ('G' == c)) cnt++;
            }
            if (cnt > max) {
                max = cnt;
                subs = s;
            }
        }
        cout << subs << endl;
    }
    
    return 0;
}