#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<deque>
#include<fstream>
using namespace std;
char a[100001]={0};
long long M;
long long tu,tf,td;//上坡,平地,下坡
long long T;
int main(){
ifstream fin("HAOI2013T1.in");
ofstream fout("HAOI2013T1.out");
fin>>M>>T>>tu>>tf>>td;
long long i;
long long sum=0;
for(i=0;i<T;i++) fin>>a[i];
i=0;
while(sum<=M&&i<=T){
if(a[i]=='u'){
sum+=tu,sum+=td;
}
else if(a[i]=='f'){
sum+=tf,sum+=tf;
}
else if(a[i]=='d'){
sum+=tu,sum+=td;
}
i++;
}
fout<<i-1<<endl;
fin.close();
fout.close();
return 0;
}