eolymp
bolt
Try our new interface for solving problems

Path

A new robot \textbf{PZ07} is now in the testing room. The testing room is a parallelepiped \textbf{n}×\textbf{m}×\textbf{k}. The robot knows a sequence of instructions to execute. The instructions are: "\textbf{u}" - one position up, "\textbf{d}" - one position down, "\textbf{l}" - one position left, "\textbf{r}" - one position right, "\textbf{f}" - one position forward, "\textbf{b}" - one position backward. Robot executes its program one by one. If the instruction tells the robot to go outside the room, the robot ignores this instruction. You are given a sequence of instructions, but you don't know the initial location of the robot. Your task is to find the number of positions in which the robot may finish its trip. \InputFile The first line of the input contains three integers \textbf{n}, \textbf{m} and \textbf{k} (\textbf{1} ≤ \textbf{n}, \textbf{m}, \textbf{k} ≤ \textbf{10^5}) --- width (left-right dimension), height (up-down dimension) and length (forward-backward dimension). The second line contains the sequence of instructions. There will be no more than \textbf{10^5} instructions. \OutputFile Output the number of positions where robot may finish its trip after executing the given program.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1 1 1
uuuur
Output example #1
1
Author Dmitry Gozman
Source Dmitry Gozman Contest 1, Petrozavodsk training camp, January 2007