#include <bits/stdc++.h>
using namespace std;
char s[500];
char s1[201];
int main() {
  gets(s);
  int k;
  scanf("%i", &k);
  for (int i = 0; i < k; i++) s1[i] = '*';
  strcpy(s1 + k, "");
  strcpy(s + strlen(s), s1);
  int len = strlen(s);
  int mx = 0;
  for (int i = len / 2; i >= 0; i--) {
    for (int j = 0; j < len - i; j++) {
      bool ASA = 1;
      for (int k = j; k < j + i; k++)
        if ((s[k] == s[k + i] || s[k + i] == '*') || s[k] == '*')
          continue;
        else {
          ASA = 0;
          break;
        }
      if (ASA) {
        printf("%i", 2 * i);
        return 0;
      }
    }
  }
}
