Problem:
	
A: 不思議な植物

	
問題

	

		あるところに不思議な $X$ [cm] の植物が生えている.
		この植物は以下の不思議な性質を持っている.
	

	

		

			この植物に "nobiro" と声を掛けると, その植物は $A$ [cm] 成長する.
		

		

			この植物に "tidime" と声を掛けると, その植物は $B$ [cm] 成長する.
		

		

			この植物に "karero" と声をかけると, その植物は $0$ [cm] になる.
		

	

	

		ただし, この植物は負の長さにはならないとする.
		具体的には, $C$ [cm] の状態から $D$ [cm] $(C + D \lt 0)$ 成長するとき, 植物は $0$ [cm] になったときに成長が止まる.
	

	

			この植物に $N$ 日間, 毎日一度だけ "nobiro", "tidime", "karero" のうちどれか
			一つの言葉をかけた. $N$ 日後の植物の長さ [cm] を求めよ.
	

	
制約

	

		
入力値は全て整数である.

		
$0 \leq X \leq 100$

		
$-100 \leq A,B \leq 100$

		
$1 \leq N \leq 1000$

		
$S_i$ は "nobiro", "tidime" または "karero" のいずれかである.

	

	

	

	
入力形式

	
 入力は以下の形式で与えられる. 

	

		$X\ A\ B$

		$N $

		$S_1$

		$S_2$

		$\vdots$

		$S_N$

	

	
出力

	

		$N$ 日後の植物の長さを出力せよ. また末尾に改行を出力せよ.
	

	
サンプル

	
サンプル入力 1

	

10 30 10
3
nobiro
nobiro
tidime

	
サンプル出力 1

	

80

	
サンプル入力 2

	

10 -20 -30
1
nobiro

	
サンプル出力 2

	

0



Sample input:
10 30 10
3
nobiro
nobiro
tidime


Sample output:
80

Submission status: Accepted

Solution code:
X,A,B = map(int,input().split())
N = int(input())
for i in range(N):
  word = input()
  if word == "nobiro":
    X = X + A
  elif word == "tidime":
    X = X + B
  elif word == "karero":
    X = 0
  
  if X < 0:
    X = 0
print(X)

Submission status: Accepted

Solution code:
x, a, b = map(int, input().split())
n = int(input())
for i in range(n) :
    s = input()
    if s == 'nobiro' :
        x += a
        if x < 0 :
            x = 0
    elif s == 'tidime' :
        x += b
        if x < 0 :
            x = 0
    else :
        x = 0
print(x)

Submission status: Accepted

Solution code:
x,a,b = map(int,input().split())
for i in range(int(input())):
    w = input()
    if w == "nobiro":
        x = max(0,x+a)
    elif w == "tidime":
        x = max(0,x+b)
    else:
        x = 0
print(x)

Submission status: Accepted

Solution code:
x, a, b =map(int, input().split())
n = int(input())
voice = [input() for _ in range(n)]
for i in voice:
  if i == "nobiro":
    x += a
  elif i == "tidime":
    x += b
  elif i == "karero":
    x = 0
  if x < 0:
    x = 0
print(x)

Submission status: Accepted

Solution code:
X,A,B = map(int,input().split())
N = int(input())
for i in range(N):
    S = input()
    if S == "nobiro":
        X += A
    elif S == "tidime":
        X += B
    else:
        X = 0
    if X < 0:
        X = 0
print(X)

Submission status: Accepted

Solution code:
x, a, b = (int(y) for y in input().split())
n = int(input())

for i in range(n):
    s = input()
    if s[0] == "n" :
        x = max(0,x + a)
    elif s[0] == "t" :
        x = max(0,x + b)
    else:
        x = 0
print(x)

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))
X, A, B = inpl()

for _ in range(int(input())):
    S = input()
    if S == "karero":
        X = 0
    else:
        X = max(0, X + [A, B][S == "tidime"])

print(X)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
x, a, b = map(int, input().split())
n = int(input())
for _ in range(n):
    s = input()
    if s == 'nobiro':
        x = max(0, x + a)
    elif s == 'tidime':
        x = max(0, x + b)
    else:
        x = 0
print(x)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x,a,b = LI()
    n = II()
    ans = x
    for _ in range(n):
        s = S()
        if s == list("nobiro"):
            ans += a
        elif s == list("tidime"):
            ans += b
        else:
            ans = 0
        ans = max(ans, 0)
    print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Submission status: Accepted

Solution code:
x,a,b=(int(f) for f in input().split())
n = int(input())
i=0
for i in range(n):
    str = input()
    if str == "nobiro":
        x += a
    elif str == "tidime":
        x += b
    elif str == "karero":
        x = 0
    if x < 0:
        x = 0
        
print(x)

Submission status: Accepted

Solution code:
X,A,B = map(int,input().split())
N = int(input())
S = [input() for i in range(N)]

for s in S:
  if s=='nobiro':
    X += A
  elif s=='tidime':
    X += B
  else:
    X = 0
  if X < 0: X = 0
print(X)

Submission status: Accepted

Solution code:
X, A, B = map(int, input().split())
N = int(input())
for _ in range(N):
    s = input()
    if s=="nobiro":
        X += A
    elif s=="tidime":
        X += B
    else:
        X = 0
    X = max(0, X)
print(X)

Submission status: Accepted

Solution code:
#!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()