#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<algorithm>

using namespace std;

int pos, N, ans, cat;
char sir[1009];

int Get ()
{
    int x = 0;
    while (sir[pos] >= '0' && sir[pos] <= '9' && pos <= N)
        x = x * 10 + sir[pos ++] - 48;
    return x;
}

int main()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

while (!feof (stdin))
{
    gets (sir + 1);
    if (feof (stdin))
        break;
    ans = 0;
    N = strlen (sir + 1);
    pos = 1;
    if (sir[1] == 'u')
        pos = 10;
    if (sir[pos] == 's')
        cat = 2, pos += 6;
    else
    if (sir[pos] == 'i')
        cat = 4, pos += 4;
    else
        cat = 1, pos += 5;
    while (pos <= N)
    {
        while (sir[pos] != ',' && sir[pos] != '[')
            pos ++;

        if (sir[pos] == ',')
        {
            ans ++, pos ++;
            continue;
        }

        pos ++;
        int tot_curr = 1;
        while (1)
        {
            int curr = Get ();
            tot_curr *= curr;
            pos ++;
            if (sir[pos] == ',' || pos > N || sir[pos] != '[')
                break;
            pos ++;
        }
        ans += tot_curr;
        pos ++;
    }
    printf ("%d\n", ans * cat);
}


return 0;
}