The Robot
Limits: 2 sec., 256 MiB
A robot is located in a rectangular parallelepiped of size \(n \times m \times k\) consisted of \(1 \times 1 \times 1\) cubes. The robot has a sequence of commands to do. There are the following types of commands.
r— move one position right, but no further than \(n\).l— move one position left, but no further than 1.u— move one position up, but no further than \(m\).d— move one position down, but no further than 1.f— move one position front, but no further than \(k\).b— move one position back, but no further than 1.
If a command moves the robot outside of the parallelepiped he just ignores it.
You are given a sequence of commands, but you don’t know the starting position. Find the total number of positions where the robot could finish.
Input
The first line contains three integers \(n\), \(m\) and \(k\). The second line contains a sequence of commands that the robot performs.
Output
A single integer — the answer to the problem.
Constraints
\(1 \le n, m, k \le 10^6\),
The number of commands in the sequence is up to \(10^6\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 2 2 2 ulf | 1 |
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|