jtifziirovbklaioslunwvtdavraandnzcwqbealbvqonoxufqrsewwrzvkrecrfqhdduwmcdcdhdtvpyshfhgdwdkmglskidhzayvouwhumzhcphocqyfcdddhzayvouwhumzhcphocqyfcddayfakoxofjgusuonehbxbokjsdlktqrcdurogxltsysyjbiagrvhky
32
 kbxuunznjtxutlauuuipifggjjkequbpvbagmxojhgxtakxioxsmrmoatlyzwsygibhafspqnfbycyztxmtpirqcyhalluhhubne
100
 zwvrx
3
 wccknxhbqzjwaseubvizxuisnzneatgjhaatrfydssgzufyztesrxnjlbhckybqlbncvqgjcoupirpqnnmacejicjzhattqolmclqnotctcsliyvjwutvrtrhichssehtlwbrq
123
 cznjenwypyeulxzdxfhalfbyefhhgieybtzjmbdirrpybxnftpcqfhrhiifsfkllztwejdvhvtnxecnfgwwxhhcsjsqzhrjddauttbxphfzljgbvcqshateqeulxzdxfhalfbyefhhgieybtzjmbdirrpybxnftpcqfhrhiifsfkllztwejdvhvtnxecnfgwwxhhcsjs
41
 ezlrqvaeekbnkqqjcijtkaoisqpbguqfsqxtzjotdhtrnaoxutybbqzzhrqvaeekbnkqqjcijtkaoisqpbguqfsqxtzjotdhtrnaoxutybbqzzhzoeptxwaunvarfcapxsnamwjyqpxbiegizqotuqen
15
 zumtumtlitf
2
 wqlvwkiiqfmesejedhyjjfgzqfmiqyaiqefzaywrdundcmbfvhdflrpvkitbltbrzedvozltptkaanbpmjvsdnpthcepfydrdlscexczxwzyatupzlxdhnezdsipeyjqmbvoavsgeuulkqkexpwpttvxeovcjrqnzdeiaatzglvwkiiqfmesejedhyjjfgzqfmiqyaiq
141
 nemtbujbscvkgxnbqboeohzfozihjvhcllfseiouggzojhqcoqrvtdsgkubiophnhahgplhtjxblicnavkayzsydmxphgfvhlllontqfpqitrpjiadpmogtqyjhqfpqitrpjiadpmogtqyjhvaopbzglvdmwzsrhtsszyengbihrrzljvofgugmjedgujhzvlebpprue
140
 skllmtqzajnzjkuflkazjku
10
 ngkdgsdxouojadjqzgxewuuyxdlxulgrblxpkyzhgmkeatmhvbdelmxxrqtsarfvotcxfuiqsxbnczbadelhxtlfwrnbisayeveiejvycllhkictyyriqseznziyurlgiejvycllhkictyyriqseznziyurlgwiubyvqfmabhstqalicamyholkqlvtjfhcfbyr
133
 uzfvkgoaimitrlfjn
43
 ijtvifbuajod
5
 cxpleheyfwu
132
 lfydqwrwevvvclkkainwxwvqf
33
 kitxizqtbzwjqldmhwpmznaoddtgqzithwvyeyuixxhlnmksmsysikftzrskbnriebbwzermgcxalwpmznaoddtgqzithwvyeyuixxhlnmksmsy
32
 uqytussdzppiuwxterrfyrwtsrkdpfzhjpeuuulopnnjtltdtlkzwixouxteuheqaxhaicoeveggwkcnkamluxykyktmvafajfnxmeuuulopnnjtltdtlkzwixouxteuheqaxhaicoeveggwkcnkamluxykyktmvafajfnxmefkurbbcbesiwcauwmlhmfslcavsreea
41
 xaxgnvphqavbuxzkcsptsih
150
 zonkpassuptcnpeoogztfpaspwdwnmiwsxeskfajlpfswzrdcxhlzxrgddtgmnngevbiybdnwelkzonhrzgldriyymrzduulifphxypcaqurgeqitkxxnsqdpsxattjoncmhihgxdaxixkmockynyjefvhrzgldriyymrzduulifphxypcaqurgeqitkxxnsqdpsxatt
200
 ifglyzxttgfpcgvpfmfmjhuzmgmaiivnbrzjevgxosclwqfewklzstkjmnjmqgpeshndmzrtthpjbhuqoldgvkkmkqinkptatpytrchkvjyeimsfmjhuzmgmaiivnbrzjevgxosclwqfewklzstkjmnjmqgpeshndmzrtthpjbhuqoldgvkkmkqinkptatpytrchkvjy
15
 mklxokaoaxzccddmsxzc
41
 eluswgbaoqmkfymoidkripnpgmbvhydcuupfhecefgosemhverqwzxklzzacdgcrrlzdnocxmzxtiamqpxspfogqhrlsnfzdexamrkowqpqggolnrvxfhenedmfzngnavgnjkzsnkjjjfcgfqjuywmrt
115
 xbmrxbmrkzovhb
3
 ktkkckrzvjhdspjmtljrmwgfoxeuadhajkfjpcmquqldlkutwyqaupnypwqfbxbuaaywcflplmqxnvwmkzpdvvkgxkmsggxmdangeyudqrgrihgbljrmwgfoxeuadhajkfjpcmquqldlkutwyqaupnypwqfbxbuaaywcflplmqxnvwmkzpdvvkgxkmsggxmdangeyudq
57
 thdnszfpaznmjlzacpovjcvybdkynhnvkaxvncfpofvnfpkggyfvqbklvrnbwpjswbrvjvqyzheslzxvuuqpbrvjvqyzheslzxvuuqprxasesuweenacripkyevplccdlxocfuqklypxactpajkmhcsgbxwgznizwndthualdbbgxhrtdrodoiddzdmxtatssfsuksqz
23
 fonwebmlwaxthdwche
57
 pdgrwrozhkrwwgebwvuilwm
32
 jhfwjyyzwrjiyrrgveiqkoltivghgkontrqragikttxxuwszjwqhwxindyrdqhucnbwgwrppgqmsasrzohezjlfmkzsqptwpratprcrxyxecnlsaiqrvimihmhjfgzwdtvmfhgbuonpsblphyoxzclkrwbwrkasahiirzqlfjdoomlosltldbpomyyhmdwfchzxnmwlh
200
 ayi
10
 eexlzphiay
1
 auxrkguktewrcwwklhmuxkgdialidacmjinwcsrtfrtdsvqsbwuqtsrmsyizsvdkbqwrbuphqqvzktqkskylnnqbezibqnaytuuqddrigdkbqwrbuphqqvzktqkskylnnqbezi
23

64
 200
 6
 246
 220
 108
 6
 334
 280
 20
 266
 60
 10
 142
 58
 120
 134
 172
 400
 186
 60
 230
 8
 190
 46
 74
 54
 400
 12
 2
 86

#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long a, long long b) {
  if (!a || !b) return 1;
  while (a %= b ^= a ^= b ^= a)
    ;
  return b;
}
bool srt(int &a, int &b) {
  if (a > b)
    return --a > ++b;
  else if (b >= a)
    return --b > ++a;
}
bool srt(string &a, string &b) {
  if (a.size() > b.size())
    return true;
  else if (a.size() < b.size())
    return false;
  return 0;
}
class A {
 private:
  vector<string> vec;
  int n, c = 0;
  string s;
  void gen() {
    for (int i = 0; i < s.size(); i++) {
      string tmp = "";
      for (int j = i; j < s.size(); j++) {
        tmp += s[j];
        if (tmp.size() % 2 == 0) vec.emplace_back(tmp);
      }
      int h = tmp.size() + n;
      if (h % 2 || tmp != s.substr(s.size() - tmp.size(), tmp.size())) continue;
      h /= 2;
      bool good = 1;
      for (int j = 0; j < tmp.size() - h && tmp.size() > h; j++)
        if (tmp[j] != tmp[j + h]) good = 0;
      if (good) c = max(c, h * 2);
      vec.pop_back();
    }
  }

 public:
  A() {
    cin >> s >> n;
    gen();
    for (auto &(i) : (vec)) {
      bool good = 1;
      for (int(i) = (0); (i) < (vec.size()); ++(i)) {
        for (int j = 0; j < vec[i].size() / 2 && vec[i].size() % 2 == 0; j++)
          if (vec[i][j] != vec[i][j + vec[i].size() / 2]) good = 0;
        if (good) c = max(c, (int)vec[i].size());
      }
    }
    cout << c << "\n";
  }
};
class B {
 private:
 public:
  B() {}
};
class Game {
 private:
  unsigned long long __gcd(unsigned long long x, unsigned long long y) {
    while (x && y) {
      if (x >= y)
        x %= y;
      else
        y %= x;
    }
    if (!x) return y;
    return x;
  }
  string tmp;
  char minchar(string &s) {
    char res = s[0];
    for (int(i) = (0); (i) < (s.size()); ++(i)) {
      res = min(res, s[i]);
    }
    return res;
  }
  char maxchar(string &s) {
    char res = s[0];
    for (int(i) = (0); (i) < (s.size()); ++(i)) {
      res = max(res, s[i]);
    }
    return res;
  }
  void Gen(string &s, int i, int j, unordered_map<string, bool> &maping) {
    if (i == s.size()) {
      if (minchar(s) >= '0' && maxchar(s) <= '9') maping[s] = 1;
      return;
    }
    s[i] = (tmp[i] + j);
    Gen(s, i + 1, j, maping);
    s[i] = (tmp[i] - j);
    Gen(s, i + 1, j, maping);
    s[i] = tmp[i];
  }

 public:
  Game() {
    int c, co = 1;
    cin >> c;
    while (co <= c) {
      int n, res = 0;
      scanf("%d", &n);
      unordered_map<string, bool> maping;
      for (int(i) = (0); (i) < (n); ++(i)) {
        string x;
        cin >> x;
        tmp = x;
        if (!maping[(x)]) {
          maping[(x)] = 1;
          for (int(j) = (1); (j) < (10); ++(j)) {
            Gen(x, 0, j, maping);
          }
          res++;
        }
      }
      printf("Case %d: %d\n", co, res);
      co++;
    }
  }
};
class C {
 private:
 public:
  C() {}
};
class D {
 private:
 public:
  D() {}
};
class E {
 private:
 public:
  E() {}
};
int main() { A(); }
