#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int u , d ,f;
int maxMinuate;
int nowMinuate=0;
int step=0;
int road [100010];
int len;
scanf("%d %d %d %d %d",&maxMinuate,&len,&u,&f,&d);
for(int i = 0 ;i<len;i++)
{
scanf("%d",&road[i]);
}
for(int i = 0; i<len;i++)
{
int k ;
if(road[i]=='u' || road[i]=='d')
k = u+d;
else if(road [i]== 'f')
k = 2* f;
if(nowMinuate + k > maxMinuate)
{
break;
}
else
{
step++;
nowMinuate += k;
}
}
printf("%d",step);
}
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int u , d ,f;
int maxMinuate;
int nowMinuate=0;
int step=0;
int road [100010];
int len;
scanf("%d %d %d %d %d",&maxMinuate,&len,&u,&f,&d);
for(int i = 0 ;i<len;i++)
{
scanf("%d",&road[i]);
}
for(int i = 0; i<len;i++)
{
int k ;
if(road[i]=='u' || road[i]=='d')
k = u+d;
else if(road [i]== 'f')
k = 2* f;
if(nowMinuate + k > maxMinuate)
{
break;
}
else
{
step++;
nowMinuate += k;
}
}
printf("%d",step);
}