Codeforces Round 253 (Div. 2)
B
Kolya and Tandem Repeat
Codeforces
1500
原题
← AC →
翻译中…

Kolya got string $*s*$ for his birthday, the string consists of small English letters. He immediately added $*k*$ more characters to the right of the string.

翻译中…

Then Borya came and said that the new string contained a tandem repeat of length $*l*$ as a substring. How large could $*l*$ be?

翻译中…

See notes for definition of a tandem repeat.

翻译中…

Input

翻译中…

The first line contains $*s*$ ($1 ≤ |*s*| ≤ 200$). This string contains only small English letters. The second line contains number $*k*$ ($1 ≤ *k* ≤ 200$) — the number of the added characters.

翻译中…

Output

翻译中…

Print a single number — the maximum length of the tandem repeat that could have occurred in the new string.

翻译中…

Note

翻译中…

A tandem repeat of length $2*n*$ is string $*s*$, where for any position $*i*$ ($1 ≤ *i* ≤ *n*$) the following condition fulfills: $*s*_{*i*} = *s*_{*i* + *n*}$.

翻译中…

In the first sample Kolya could obtain a string aabaab, in the second — aaabbbbbb, in the third — abracadabrabracadabra.

翻译中…

样例

Input #1
aaba
2
Output #1
6
InputCopy OutputCopy
Input #2
aaabbbb
2
Output #2
6
InputCopy OutputCopy
Input #3
abracadabra
10
Output #3
20
InputCopy OutputCopy
题目信息
题号
443B
时间限制
2 s
内存限制
256 MB
标签
暴力
模拟
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。