problem

A mysterious $ X $ [cm] plant grows in one place. This plant has the following mysterious properties.

* Say "nobiro" to this plant and it will grow $ A $ [cm].
* Say "tidime" to this plant and it will grow $ B $ [cm].
* If you say "karero" to this plant, it will be $ 0 $ [cm].



However, this plant does not have a negative length. Specifically, when it grows from the state of $ C $ [cm] to $ D $ [cm] $ (C + D \ lt 0) $, it is a plant. Stops growing when it reaches $ 0 $ [cm].

Say one of "nobiro", "tidime", "karero" to this plant only once a day for $ N $ days. Find the length [cm] of the plant after $ N $ days.



output

Print the length of the plant after $ N $ days. Also print a newline at the end.

Example

Input

10 30 10
3
nobiro
nobiro
tidime


Output

80
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    x,a,b = LI()
    n = I()
    ans = x
    for _ in range(n):
        s = input()
        if s == "nobiro":
            if ans + a >= 0:
                ans += a
            else:
                ans = 0
        elif s == "tidime":
            if ans + b >= 0:
                ans += b
            else:
                ans = 0
        else:
            ans = 0
    print(ans)
    return

if __name__ == "__main__":
    solve()

