#include<iostream>
#include<string.h>
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include <queue>
#include <map>
#include <fstream>

using namespace std;




map<const char*, int> tip;
char consoane[]="bcdfghjklmnpqrstvwxyz",vocale[]="aeiou",cifre[]="0123456789",separator[]=" ,\n";
char sir[1002],sir1[1000][1000],pasareasca[10000],cuv[10],*p;
int i,j=1,n,m,cuvinte;

char linie[105], *var[105], delim[105] = "][\n";

int main( )

{
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);

      for(char c = 'a' ; c <= 'z' ; c++) // Construct the delimiter containing
            delim[c - 'a' + 3] = c;        // all letters and ], [, newline

       while(!feof(stdin)){                            // While we aren't done
            fgets(linie, 105, stdin);                    // Read a liniearation into linie
           scanf(" ");                                 // Trigger EOF if necessary

        char *last_space = strrchr(linie, ' ');      // Find the last space character
           *last_space = 0;                            // Split the string at this char
          char *type = linie, *vars = last_space + 1;  // into the type and a string of vars
          //type contine linia pana la ultimul spatiu inaite de variabile
          //vars contine linia cu toate variabilele



           int varn = 0, sum = 0;
           var[0] = strtok(vars, ",");                 // Split the string of vars into an array
           while((var[++varn] = strtok(NULL, ",")));
           //var contine indexate toate variabilele


        for(int i = 0 ; i < varn ; i++){            // For each variable
               int nr = 1;                             // nr is the dimension of the variable (number of elements)
            char *part = strtok(var[i], delim);     // Split it into parts using delim
            while(part) {                           // Each part is a dimension of the vector
                nr *= atoi(part);                   // Multiply nr by the dimension
                   part = strtok(NULL, delim);
             }
              sum += nr * 4;                          // int is the default type and has 4 bytes
          }

           if(strstr(type, "short"))
               sum /= 2;
           if(strstr(type, "char"))
              sum /= 4;
        printf("%d\n", sum);
       }

       return 0;

   }