class HelloWorld {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int n = in.nextInt();
        float max = -1f;
        String tmp = null;
      //暴力解法  两层循环 
        for (int i = 0; i < s.length(); i++) {
            int k = i + n;
          //截串  统计C G个数
            if (k <= s.length()) {
                String sub = s.substring(i, k);
                int c = 0, f = n, tt = n - 1;
                while (f > 0) {
                    if (sub.charAt(tt) == 'C' || sub.charAt(tt) == 'G') {
                        c++;
                    }
                    f--;
                    tt--;
                }
                float e = c*10f/(n*10f);
              // 判断比例
                if ( e == 1f) {
                    System.out.println(s.substring(i, k));
                    break;
                } else {
                    if (max < e)  {
                        tmp = s.substring(i, k);
                        max = e ;
                    }
                }
            }
        }
        System.out.println(tmp);
    }
}