#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <vector>

using namespace std;

char A[202];

int getsize(int x)
{
	int res = 0, snow = 1;
	while (A[x] != 0)
	{
		if (A[x] == ',')
		{
			res += snow;
			snow = 1;
			++x;
		}
		else if (A[x] >= 'a' && A[x] <= 'z')
			++x;
		else if (A[x] == '[')
		{
			++x;
			int num = 0;
			while (A[x] != ']')
			{
				num = num * 10 + (A[x] - '0');
				++x;
			}
			snow *= num;
			++x;
		}
	}
	res += snow;
	
	return res;
}

int main()
{
	cin.sync_with_stdio(false);

	while (cin.getline(A, 200))
	{
		int now = 0;
		if (A[now] == 'u') now += 9;
		
		int size = 0;
		if (A[now] == 'c')
		{
			size = 1;
			now += 5;
		}
		else if (A[now] == 's')
		{
			size = 2;
			now += 6;
		}
		else if (A[now] == 'i')
		{
			size = 4;
			now += 4;
		}
		
		cout << getsize(now) * size << '\n';
	}
}