#define _CRT_SECURE_NO_DEPRECATE

#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <iterator>
#include <queue>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

#define DMAX 201
#define MOD 1000000007

char decl[DMAX], nr[12];
unsigned long long type;
unsigned long long memory;

int main(){
	unsigned long long i;

	//freopen("test.in", "r", stdin);
	//freopen("test.out", "w", stdout);

	while (!cin.eof()){
		memory = 0;

		cin.getline(decl, 201, '\n');
		if (decl[0] == 'u'){
			switch (decl[9]){
			case 'c': type = 1; break;
			case 's': type = 2; break;
			case 'i': type = 4; break;
			default: break;
			}
		}
		else{
			switch (decl[0]){
			case 'c': type = 1; break;
			case 's': type = 2; break;
			case 'i': type = 4; break;
			default: break;
			}
		}

		int k;
		long long crMem = 1;
		for (i = 0; i <= strlen(decl); i++){
			if (decl[i] == ',' || i == strlen(decl)) memory += crMem*type, crMem = 1;
			if (decl[i] == '['){
				k = 0;
				while (decl[++i] >= '0' && decl[i] <= '9'){
					nr[k++] = decl[i];
				}
				nr[k] = 0;
				crMem *= atol(nr);
			}
		}

		cout << memory << '\n';
	}

	return 0;
}