奶牛贝茜

来源:互联网 发布:手机端淘宝详情页制作 编辑:程序博客网 时间:2024/04/26 19:21
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
    long M, T;
    int U,F,D;
    long route = 0, len = 1;
    char s;
    scanf("%d%d%d%d%d", &M,&T,&U,&F,&D);
    while(T--){
        cin >> s;
        if(s == 'f')route = route + F + F;
        else route = route + U + D;
        if(route <= M)len++;
        else break;
    }
    printf("%d\n", len-1);
    return 0;
}