#include <bits/stdc++.h>
using namespace std;
int N, T, U;
string S;
void read(void);
void prep(void);
void soups_on(void);
bool yee_haw(int);
int main() {
  read(), prep(), soups_on();
  return 0;
}
void read(void) { cin >> N >> T >> S; }
void prep(void) {
  S.replace(0, 0, " ");
  U = count(S.begin(), S.end(), 'H');
}
void soups_on(void) {
  int low = 0, up = U + 1, mid;
  while (low < up) {
    mid = (low + up) / 2;
    if (!yee_haw(mid))
      low = mid + 1;
    else
      up = mid;
  }
  if (low == U + 1)
    cout << "-1\n";
  else
    cout << low << "\n";
}
bool yee_haw(int bnd) {
  int mt, p, t, k, lst, ld;
  vector<int> di, li;
  lst = int(S.rfind('H'));
  p = t = 0, k = bnd, ld = 0;
  while (p < N && (p < lst || k < 0)) {
    ++p, ++t;
    if (S[p] == 'H') {
      if (k-- == 0) ld = p;
    } else if (S[p] == 'S') {
      if (++k == 0) di.push_back(p - ld), li.push_back(p);
    }
  }
  if (k < 0) return false;
  mt = t = t + 2 * accumulate(di.begin(), di.end(), 0);
  for (int i = di.size() - 1; i >= 0; --i)
    t += (p - li[i]) - di[i], p = li[i] - di[i], mt = min(mt, t);
  return mt <= T;
}
