#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int x,a,b;
  cin>>x>>a>>b;
  int n;
  cin>>n;
  string s[1000];
  rep(i,n){
    cin>>s[i];
    if(s[i]=="nobiro"){
      x+=a;
      if(x<0) x=0;
    }else if(s[i]=="tidime"){
      x+=b;
      if(x<0) x=0;
    }else{
      x=0;
    }
  }
  cout<<x<<endl;

  return 0;
}

