from collections import Counter
S=input()
K=int(input())
S_double = S*2
n = 0
if len(set(list(S)))==1:
    print(len(S)*K//2)
    exit()
while n< len(S_double)-1:
    if S_double[n] ==S_double[n+1]:
        S_double = S_double[:n+1]+' '+S_double[n+2:]
    n += 1
ans = Counter(S_double[:len(S)])[' '] + Counter(S_double[len(S):])[' ']*(K-1)
print(ans) from collections import Counter S=input() S input() input K=int(input()) K int(input()) int input() input S_double = S*2 S_double S*2 S 2 n = 0 n 0 if len(set(list(S)))==1:
    print(len(S)*K//2)
    exit() len(set(list(S)))==1 len(set(list(S))) len set(list(S)) set list(S) list S 1 print(len(S)*K//2) print len(S)*K//2 len(S)*K len(S) len S K 2 exit() exit while n< len(S_double)-1:
    if S_double[n] ==S_double[n+1]:
        S_double = S_double[:n+1]+' '+S_double[n+2:]
    n += 1 n< len(S_double)-1 n len(S_double)-1 len(S_double) len S_double 1 if S_double[n] ==S_double[n+1]:
        S_double = S_double[:n+1]+' '+S_double[n+2:]
     S_double[n] ==S_double[n+1] S_double[n] S_double n S_double[n+1] S_double n+1 n 1 S_double = S_double[:n+1]+' '+S_double[n+2:] S_double S_double[:n+1]+' '+S_double[n+2:] S_double[:n+1]+' ' S_double[:n+1] S_double :n+1 n+1 n 1 ' ' S_double[n+2:] S_double n+2: n+2 n 2 n += 1 n 1 ans = Counter(S_double[:len(S)])[' '] + Counter(S_double[len(S):])[' ']*(K-1) ans Counter(S_double[:len(S)])[' '] + Counter(S_double[len(S):])[' ']*(K-1) Counter(S_double[:len(S)])[' '] (S_double[:len(S)]) Counter S_double[:len(S)] S_double :len(S) len(S) len S ' ' Counter(S_double[len(S):])[' ']*(K-1) Counter(S_double[len(S):])[' '] (S_double[len(S):]) Counter S_double[len(S):] S_double len(S): len(S) len S ' ' K-1 K 1 print(ans) print ans ans = Counter(S_double[:len(S)])[' '] + Counter(S_double[len(S):])[' ']*(K-1) Counter(S_double[:len(S)])[' '] + Counter(S_double[len(S):])[' ']*(K-1) ans S=input() input() S n += 1 1 n n = 0 0 n S_double = S*2 S*2 S_double S_double = S_double[:n+1]+' '+S_double[n+2:] S_double[:n+1]+' '+S_double[n+2:] S_double K=int(input()) int(input()) K
from collections import Counter
S=input()
K=int(input())
S_double = S*2
n = 0
if len(set(list(S)))==1:
    print(len(S)*K//2)
    exit()
while n< len(S_double)-1:
    if S_double[n] ==S_double[n+1]:
        S_double = S_double[:n+1]+' '+S_double[n+2:]
    n += 1
ans = Counter(S_double[:len(S)])[' '] + Counter(S_double[len(S):])[' ']*(K-1)
print(ans)
