edist' :: Char -> String -> Int
edist' h [] = 0
edist' h (x:[])
	| h == x    = 1
	| otherwise = 0
edist' h (x:x':[])
	| x == x'   = 1
	| h == x'   = 1
	| otherwise = 0
edist' h (x:x':xs)
	| x == x'   = 1 + edist' h xs
	| otherwise = edist' h (x':xs)

edist :: String -> Int
edist xs = edist' (head xs) xs

main :: IO ()
main = do
	xs <- getLine
	count <- readLn
	print $ count * edist xs
