output_description: Print the resulting string.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S T
attempt: N, K = map(int, input().split())
  R, S, P = map(int, input().split())
  T = input()
  SC = 0
  
  
  def MaxScore(n, t):
      SC = 0
      if t[0] == "r":
          SC += P
      elif t[0] == "s":
          SC += R
      else:
          SC += S
      NC = 1
      for i in range(1, n):
          if t[i] == "r":
              if t[i] != t[i - 1]:
                  SC += P
                  NC = 1
              elif t[i] == t[i - 1] and NC % 2 == 0:
                  SC += P
                  NC += 1
              else:
                  NC += 1
          elif t[i] == "s":
              if t[i] != t[i - 1]:
                  SC += R
                  NC = 1
              elif t[i] == t[i - 1] and NC % 2 == 0:
                  SC += R
                  NC += 1
              else:
                  NC += 1
          else:
              if t[i] != t[i - 1]:
                  SC += S
                  NC = 1
              elif t[i] == t[i - 1] and NC % 2 == 0:
                  SC += S
                  NC += 1
              else:
                  NC += 1
      return SC
  
  
  for i in range(K):
      Ti = [T[j] for j in range(N) if j % K == i]
      Ti = "".join(Ti)
      if (N - i) % K == 0:
          Ni = (N - i) // K
      else:
          Ni = (N - i) // K + 1
      SCi = MaxScore(Ni, Ti)
      SC += SCi
  
  print(SC)
  
problem_description: Statement
  
  Given are two strings S and T consisting of lowercase English letters.
  Concatenate T and S in this order, without space in between, and print the
  resulting string.
samples: [{"input": "oder atc", "output": "atcoder\n    \n\nWhen S =  `oder` and T =  `atc`, concatenating T and S in this order results\nin `atcoder`.\n\n* * *"}, {"input": "humu humu", "output": "humuhumu"}]