#include <iostream>
#include <string>

using namespace std;

int x, a, b, n;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x >> a >> b >> n;
	string s;
	for(int i = 0; i < n; i++){
		cin >> s;
		if(s == "nobiro") x = max(0, x+a);
		if(s == "tidime") x = max(0, x+b);
		if(s == "karero") x = 0;
	}
	cout << x << endl;
	
	return 0;
}
