#include <iostream>
using namespace std;
int cnt1[10001][5], maxn[5];
int main()
{
string s;
cin >> s;
s += ' ';
int flag;
cin >> flag;
int cnt = 0;
bool flag1 = false;
for (int i = 0; i < s.size(); ++i)
{
if (s[i] == '(')
{
flag1 = true;
}
else if (s[i] == ')')
{
flag1 = false;
cnt += 1;
}
else
{
if (s[i] == 'L' && s[i + 1] != '\'')
{
cnt1[cnt][0] = true;
i += 1;
}
else if (s[i] == 'L')
{
cnt1[cnt][1] = true;
}
if (s[i] == 'R' && s[i + 1] != '\'')
{
cnt1[cnt][2] = true;
i += 1;
}
else if (s[i] == 'R')
{
cnt1[cnt][3] = true;
}
if (flag1 == false)
{
cnt += 1;
}
}
}
cout << cnt - 1 << endl;
if (flag == 1)
{
for (int i = 0; i < 4; ++i)
{
int ans = 0, cnt2 = 0;
for (int j = 1; j < cnt; ++j)
{
if (cnt1[j][i] == true)
{
cnt2 += 1;
}
else
{
ans = max(ans, cnt2);
cnt2 = 0;
}
}
cout << ans << " ";
}
}
return 0;
}