#include <iomanip>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#define pb push_back
using namespace std;
vector<string> buffer;
int state[256];
int findClosingBracket(int pos)
{
int b = 1;
while (++pos < buffer.size() && b != 0)
{
if (buffer[pos] == "(") b++;
if (buffer[pos] == ")") b--;
}
return --pos;
}
int solve(int start, int rep)
{
int pos;
for (int i = 0; i < rep; i++)
{
pos = start;
while (pos < buffer.size() && buffer[pos] != ")")
{
if (buffer[pos] == "CLEAR")
{
// cout << "Performing CLEAR" << endl;
state[buffer[pos+1][0]] = 0; pos += 2;
}
else if (buffer[pos] == "INCREASE")
{
// cout << "Performing INCREASE" << endl;
state[buffer[pos+1][0]]++; pos += 2;
}
else if (buffer[pos] == "PRINT")
{
// cout << "Performing PRINT" << endl;
cout << state[buffer[pos+1][0]] << " "; pos += 2;
}
else if (buffer[pos] == "REPEAT")
{
// cout << "Performing REPEAT" << endl;
pos = solve(pos + 4, state[buffer[pos+1][0]]);
}
else
{
cerr << "Error. Position: " << pos << " Token: " << buffer[pos] << endl; exit(1);
}
}
}
if (rep == 0)
pos = findClosingBracket(start);
return pos + 1;
}
int main()
{
string line;
while (getline(cin, line))
{
string processed = "";
for (char & c : line)
{
if (c == '#')
break;
processed += c;
}
istringstream iss(processed);
string token;
while (iss >> token)
buffer.pb(token);
}
// string token;
// while (cin >> token)
// buffer.pb(token);
// for (int i = 0; i < buffer.size(); i++)
// cout << setw(3) << i << " " << buffer[i] << endl;
solve(0, 1);
}