#include <iostream>
#include <cstring>
using namespace std;
int ns;
char s[1010];
long long sol;

int main()
{
	int i, tip;
	while(cin.getline(s, 1000))
	{
		sol = 0;
		ns = strlen(s);
		i = 0;
		while(s[i] == ' ')
			i++;
		if(i == ns)
		{
			cout << sol << "\n";
			continue;
		}
		if(s[i] == 'u')
		{
			while(s[i] != ' ')
				i++;
			while(s[i] == ' ')
				i++;
		}
		if(s[i] == 'c')
			tip = 1;
		if(s[i] == 's')
			tip = 2;
		if(s[i] == 'i')
			tip = 4;
		while(s[i] != ' ')
			i++;
		while(s[i] == ' ')
			i++;
		while(i < ns)
		{
			while(i < ns && s[i] != '[' && s[i] != ',')
				i++;
			if(i == ns)
			{
				sol += 1LL * tip;
				continue;
			}
			if(s[i] == ',')
			{
				sol += 1LL * tip;
				i++;
				continue;
			}
			if(s[i] == '[')
			{
				long long total, now;
				total = 1LL * tip;
				while(i < ns && s[i] != ',')
				{
					now = 0;
					i++;
					while('0' <= s[i] && s[i] <= '9')
					{
						now = now * 10LL + s[i] - '0';
						i++;
					}
					total *= now;
					i++;
				}
				i++;
				sol += total;
			}
		}
		cout << sol << "\n";
	}
	return 0;
}