#include<bits/stdc++.h>
using namespace std;
#define LOG(x) cerr<<(#x)<<" = "<<x<<"\n";
int n;
string s;
vector<int> t;
vector<int> pre;
vector<int> cntK, cntH;
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
cin>>n>>s;
vector<int> ans(n);
t.resize(n);
pre.resize(n);
cntK.resize(n);
cntH.resize(n);
for(int i=0;i<n;++i) {
t[i]=(s[i]=='H'?-1:1);
cntK[i]=s[i]!='H';
cntH[i]=s[i]=='H';
}
pre[0]=t[0];
for(int i=1;i<n;++i) {
pre[i]+=pre[i-1]+t[i];
cntK[i]+=cntK[i-1];
cntH[i]+=cntH[i-1];
}
//nem extendálható intervallumok
stack<int, vector<int>> st;
for(int i=n-1;i>=0;i--) {
while(!st.empty() && pre[st.top()]>=(i?pre[i-1]:0)) st.pop();
int until=(st.empty()?n:st.top());
if(s[i]!='H') {
int res=min(cntH[until-1]-(i?cntH[i-1]:0), cntK[until-1]-(i?cntK[i-1]:0));
ans[i]=max(ans[i], res);
}
st.push(i);
}
//szuffixek
int add=0, cnt=0, K=0, M=0, H=0;
vector<int> suf_mn(n,1e9);
vector<int> lst, dp; lst.reserve(n); dp.reserve(n);
for(int i=n-1;i>=0;i--) {
add+=t[i];
if(i==n-1) suf_mn[i]=-add+t[i];
else {
suf_mn[i]=min({suf_mn[i+1], -add+t[i]});
}
if(s[i]=='M') {
lst.push_back(suf_mn[i]);
if(!dp.empty()) dp.push_back(min(dp.back()-2, suf_mn[i]));
else dp.push_back(suf_mn[i]);
M++;
}
if(s[i]=='K') K++;
if(s[i]=='H') H++;
while(cnt<(int)dp.size() && dp[cnt]+add>=2) cnt++;
while(cnt>0 && dp[cnt-1]+add<2) cnt--;
if(suf_mn[i]+add>=0) {
int res=min(H+cnt, K+M-cnt);
ans[i]=max(ans[i], res);
}
}
for(auto i:ans) cout<<i<<" ";
cout<<"\n";
return 0;
}