func_code_string: #include <bits/stdc++.h>   using namespace std;   const int max_n = 100000;   int n, k;   char s[max_n + 5];   void solve(void);   int main(void) {     int t;     scanf( %d , &t);     while (t--) solve();     return 0;   }   void solve(void) {     scanf( %d%d , &n, &k);     scanf( %s , s);     int i, j, t, ans = 0;     int lcnt = 0;     for (i = 0; i < n; i++) {       if (s[i] ==  W ) {         if (i > 0 && s[i - 1] ==  W )           ans += 2;         else           ans++;       } else         lcnt++;     }     if (lcnt == n) {       if (!k)         printf( 0 n );       else         printf( %d n , 2 * k - 1);       return;     }     i = 0;     vector<int> gap;     while (i < n) {       if (s[i] ==  L ) {         i++;         continue;       }       j = i;       while (j < n && s[j] ==  W ) j++;       t = j;       while (t < n && s[t] ==  L ) t++;       if (t >= n) break;       gap.push_back(t - j);       i = t;     }     sort(gap.begin(), gap.end());     for (i = 0; k && i < (int)gap.size(); i++) {       if (gap[i] <= k) {         k -= gap[i];         lcnt -= gap[i];         ans += 2 * gap[i] + 1;       } else {         lcnt -= k;         ans += 2 * k;         k = 0;       }     }     if (k) {       ans += min(k, lcnt) * 2;     }     printf( %d n , ans);   }   