output_description: Print the maximum possible number of happy people after at most K operations.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      S
attempt: ## 幸福度が変わるかどうかは操作Kによって変更されたl, r番目の人間だけなので、
  ## 左右l,r番目の人間が幸福であるかどうかを見てゆく
  ## for(n)回のループでまず「既に 1 + x, 任意の r が幸福であるかどうか」を確認して、
  ## 幸福度2, 1の順でそのl,rをK回覚える
  n, k = map(int, input().split())
  humans = list(input())
  k_count = 0
  last_r = n  ## 最後に操作したr(番目)
  dev_null = 0
  
  for x in range(n - 1):
      if x == last_r:
          break  ## すべての可能性を確認した
      if x == 0:
          continue
      l = r = "n"
      if k_count == k:
          break  ## 既にK回試行したのでbreak
      if humans[x] == "L" and humans[x - 1] == "L":
          continue
      elif humans[x] == "R" and humans[x - 1] == "R" and humans[x + 1] == "R":
          continue
      else:
          ## 不幸なので、lを確定
          l = x + 1  ## 不幸な人
          if l == last_r - 1:
              break  ## 前に操作したrとlが等しい
          ## rを探す(x + 1からlast_rまで)
          for y in reversed(range(l, last_r)):  ## l, l+1, last_r - 1
              if y == n - 1 and humans[x] == "R":
                  ## 不幸なので、rを確定
                  r = y
                  last_r = r
                  k_count += 1
                  break
              elif humans[y] == "L" and humans[y - 1] == "L":
                  dev_null += 1  ## 既に同じ方向を向いてる
              elif humans[y] == "R" and humans[y + 1] == "R":
                  dev_null += 1  ## 既に同じ方向を向いてる
              else:
                  ## 不幸なので、rを確定
                  r = y
                  last_r = r
                  k_count += 1
                  break
          if l != "n" and r != "n":
              ## ともに値があるなら操作Kを実行
              for z in range(l, r + 1):
                  if humans[z - 1] == "L":
                      humans[z - 1] = "R"
                  else:
                      humans[z - 1] = "L"
  
  ## ポイントを計算
  happy_point = 0
  for x in range(n):
      if x == 0 and humans[x] == "L":
          ## do nothing
          dev_null += 1
      elif x == n - 1 and humans[x] == "R":
          ## do nothing
          dev_null += 1
      else:
          if humans[x] == "L" and humans[x - 1] == "L":
              happy_point += 1
          elif humans[x] == "R" and humans[x + 1] == "R":
              happy_point += 1
  print(happy_point)
  
problem_description: Statement
  
  There are N people standing in a queue from west to east.
  
  Given is a string S of length N representing the directions of the people. The
  i-th person from the west is facing west if the i-th character of S is `L`,
  and east if that character of S is `R`.
  
  A person is happy if the person in front of him/her is facing the same
  direction. If no person is standing in front of a person, however, he/she is
  not happy.
  
  You can perform the following operation any number of times between 0 and K
  (inclusive):
  
  Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and
  rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th
  persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the
  west will stand the (r - i)-th from the west after the operation, facing east
  if he/she is facing west now, and vice versa.
  
  What is the maximum possible number of happy people you can have?
samples: [{"input": "6 1\n    LRLRRL", "output": "3\n    \n\nIf we choose (l, r) = (2, 5), we have `LLLRLL`, where the 2-nd, 3-rd, and 6-th\npersons from the west are happy.\n\n* * *"}, {"input": "13 3\n    LRRLRLRRLRLLR", "output": "9\n    \n\n* * *"}, {"input": "10 1\n    LLLLLRRRRR", "output": "9\n    \n\n* * *"}, {"input": "9 2\n    RRRLRLRLL", "output": "7"}]