#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int kk;
  cin >> s;
  cin >> kk;
  int n = s.size();
  int maxN = n + kk;
  int ans = 1;
  int tempAns = 0;
  bool valid = false;
  for (int(i) = (ans); (i) <= (maxN / 2); ++(i)) {
    for (int(j) = 0; (j) < (n); ++(j)) {
      bool tempValid = true;
      for (int(k) = (j); (k) <= (j + (i - 1)); ++(k)) {
        if (k + i >= maxN) {
          tempValid = false;
          break;
        }
        if (k + i < n) {
          if (s[k] != s[k + i]) {
            tempValid = false;
            break;
          }
        }
      }
      if (tempValid == true) {
        valid = true;
        tempAns = i;
        break;
      }
    }
  }
  cout << 2 * tempAns << endl;
  return 0;
}
