Since communication with Mars is still complicated, some (or none, or all) of the instructions may be lost. In any case, the relative order of the instructions received by the robot will be preserved. Can you compute the total number of possible final positions of the robot?
For example, suppose that the sequence of instructions is “DRUD”. If the first and the last instructions are lost, then the robot will end at (1, 1) after one move to the right and one upwards. If no instruction is lost, the robot will end at (1, −1), etc.
Input
Input consists of several cases, each one with a string of size between 1 and 104, made up of only letters chosen among ‘L’, ‘R’, ‘U’ and ‘D’.
Output
For every case, print the total number of different positions where the robot may end.
Input
DRUD R LLLLL
Output
8 2 6