#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  int k, n, flag, max = 2;
  string s;
  cin >> s;
  n = s.size();
  cin >> k;
  int i = 0;
  while (i < n + k - max) {
    for (int j = max; j <= n + k - i; j += 2) {
      flag = 0;
      for (int index = i; index < i + j / 2; index++) {
        if ((index + j / 2) > n - 1) {
          break;
        }
        if (s.at(index) != s.at(index + j / 2)) {
          flag = 1;
          break;
        }
      }
      if (flag == 0) {
        if (j > max) max = j;
      }
    }
    i++;
  }
  cout << max << endl;
  return 0;
}
