output_description: Print the minimum number of operations required.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
      K
attempt: s = input()
  d = [c for c in s]
  n = int(input())
  l = len(d)
  count = 0
  for i in range(l - 2):
      if i == 0 and d[0] == d[l - 1] and d[i] == d[i + 1]:
          d[0] = "1"
          count += 1
      if d[i] == d[i + 1]:
          if d[i] != d[i + 2]:
              d[i] = "1"
              count += 1
          elif d[i] == d[i + 2]:
              d[i + 1] = "1"
              count += 1
  if l >= 3:
      if s[l - 2] == s[l - 1] and s[l - 3] != s[l - 2]:
          count += 1
          count *= n
      elif s[l - 2] == s[l - 1] and s[l - 2] == s[l - 3]:
          count *= n
          count += n - 1
      else:
          count *= n
  if l == 2 and s[0] == s[1]:
      count = n
  print(count)
  
problem_description: 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.
samples: [{"input": "issii\n    2", "output": "4\n    \n\nT is `issiiissii`. For example, we can rewrite it into `ispiqisyhi`, and now\nany two adjacent characters are different.\n\n* * *"}, {"input": "qq\n    81", "output": "81\n    \n\n* * *"}, {"input": "cooooooooonteeeeeeeeeest\n    999993333", "output": "8999939997"}]