#include <bits/stdc++.h>
using namespace std;
bool isGood(string s, int n) {
  for (int i = 0; i <= s.size() - n; i++) {
    bool good = true;
    for (int j = i; j < i + n / 2; j++) {
      if (s[j] != s[j + n / 2] and s[j + n / 2] != '*') {
        good = false;
        break;
      }
    }
    if (good) return true;
  }
  return false;
}
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    s += "*";
  }
  int n = s.size();
  if (n % 2) n--;
  for (int i = n; i > 0; i -= 2) {
    if (isGood(s, i)) {
      cout << i << endl;
      return 0;
    }
  }
}
