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 = str(input())
  k = int(input())
  
  
  def main(s, k):
      separation = []
      tmp = ""
      for x in range(len(s) - 1):
          tmp += s[x]
          if s[x] == s[x + 1]:
              if tmp == "":
                  tmp += s[x]
          else:
              separation.append(tmp)
              tmp = ""
      tmp += s[-1]
      separation.append(tmp)
  
      total = 0
  
      if len(separation) == 1:
          if len(separation[0]) == 1:
              return k // 2
          else:
              return (len(separation[0]) * k) // 2
  
      if (s[0] == s[-1]) and k > 1 and len(separation) > 1:
          a = len(separation[0]) // 2
          b = len(separation[-1]) // 2
          total += a
          total += b
          separation[0] += separation[-1]
          a = separation[0]
          c = (len(a) // 2) * (k - 1)
          total += c
          separation = separation[1:-1]
  
      # print(separation)
  
      for x in separation:
          total += (len(x) // 2) * k
  
      return total
  
  
  print(main(s, k))
  
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"}]