AtCoder Grand Contest 039
翻译中…
Problem Statement
翻译中…
Given is a string $S$. Let $T$ be the concatenation of $K$ copies of $S$. We can repeatedly perform the following operation: choose a character in $T$ and replace it with a different character. Find the minimum number of operations required to satisfy the following condition: any two adjacent characters in $T$ are different.
翻译中…
Constraints
翻译中…
$1 \leq |S| \leq 100$$S$consists of lowercase English letters.$1 \leq K \leq 10^9$$K$is an integer.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
S
K
翻译中…
Output
翻译中…
Print the minimum number of operations required.
翻译中…
样例
Input #1
issii
2
Output #1
4
$T$ is `issiiissii`. For example, we can rewrite it into `ispiqisyhi`, and now any two adjacent characters are different.
Input #2
qq
81
Output #2
81
Input #3
cooooooooonteeeeeeeeeest
999993333
Output #3
8999939997
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。