#D6067. Strange Plants

    ID: 5038 Type: Default 1000ms 268MiB

Strange Plants

Strange Plants

problem

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

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

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

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

output

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

Example

Input

10 30 10 3 nobiro nobiro tidime

Output

80

inputFormat

outputFormat

output

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

Example

Input

10 30 10 3 nobiro nobiro tidime

Output

80

样例

10 30 10
3
nobiro
nobiro
tidime
80