program racing;
var m,t,i,s,w:longint;
u,f,d:integer; c:char;
procedure print(k:longint);
begin
writeln(k);
close(input); close(output);
halt;
end;
begin
assign(input,'racing.in'); reset(input);
assign(output,'racing.out'); rewrite(output);
readln(m,t,u,f,d);
s:=0; w:=0; u:=u+d; f:=f+f; d:=u;
for i:=1 to t do
begin
readln(c);
case c of
'u': w:=w+u;
'f': w:=w+f;
'd': w:=w+d;
end;
inc(s);
if m=w then print(s)
else if m<w then print(s-1);
end;
end.