#include<stdio.h>
#include<string.h>
int main()
{
int n,m,i;
char a[5];
while(scanf("%d %d",&n,&m)!=EOF)
{
for(i=0;i<=m;i++)
{
gets(a);
if(a[0]=='m')
printf("%d\n",n);
if(a[0]=='e')
printf("%d\n",2*n);
if(a[0]=='l')
printf("%d\n",4*n);
}
}
return 0;
}
#include<string.h>
int main()
{
int n,m,i;
char a[5];
while(scanf("%d %d",&n,&m)!=EOF)
{
for(i=0;i<=m;i++)
{
gets(a);
if(a[0]=='m')
printf("%d\n",n);
if(a[0]=='e')
printf("%d\n",2*n);
if(a[0]=='l')
printf("%d\n",4*n);
}
}
return 0;
}