#include <bits/stdc++.h>   using namespace std;   const int MAXN = 500005;   int ult;   int cont;   int prim;   char cad[MAXN];   bool Solve(int a, int n, int T) {     int c = 0, time = 0;     queue<int> s;     prim = -1;     for (int i = 0; i < n && c < cont; i++, time++) {       if (cad[i] ==  H  && a > 0) {         c++;         a--;         if (prim == -1) prim = i;       } else if (cad[i] ==  H ) {         s.push(i);         if (prim == -1) prim = i;       } else if (cad[i] ==  S ) {         a++;         if (a >= s.size()) {           if (!s.empty()) {             int aux = abs(s.front() - i);             time += aux;             s.pop();             a--;             c++;             while (!s.empty()) {               c++;               a--;               s.pop();             }             if (c < cont) time += aux;           }         }       }       if (c == cont) ult = i;     }     time = min(time, ult + 1 + (ult - prim));     return (time <= T && c == cont);   }   int main() {     int n;     long long int T;     scanf( %d %lld , &n, &T);     scanf(  n%s , cad);     for (int i = 0; i < n; i++)       if (cad[i] ==  H ) cont++;     int ini = 0, fin = cont;     while (ini < fin) {       int med = (ini + fin) / 2;       if (!Solve(med, n, T))         ini = med + 1;       else         fin = med;     }     if (Solve(ini, n, T))       printf( %d n , ini);     else       printf( -1 n );     return 0;   }   