#include <bits/stdc++.h>
using namespace std;
char s[202];
int n, k, len, re, ch;
void solve() {
  scanf("%s %d", s, &n);
  len = strlen(s);
  for (int i = 0; i < len; i++) {
    for (int j = 2; i + j - 1 < len + n; j += 2) {
      ch = 0;
      for (int p = i + j / 2, q = 0; p < i + j && p < len; p++, q++) {
        if (s[i + q] != s[p]) {
          ch = 1;
          break;
        }
      }
      if (!ch) re = max(re, j);
    }
  }
  printf("%d\n", re);
}
int main(void) {
  solve();
  return 0;
}
