// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int X, A, B, N;
  cin >> X >> A >> B >> N;
  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    if (s == "nobiro") {
      X += A; 
    } else if (s == "tidime") {
      X += B;
    } else {
      X = 0;
    }
    X = max(0LL, X);
  }
  cout << X << endl;
}


