#K92217. Final Position of the Robot

    ID: 38149 Type: Default 1000ms 256MiB

Final Position of the Robot

Final Position of the Robot

The robot starts at the origin \((0, 0)\) on a 2D plane. It receives a series of commands represented by a string, where each command can be one of the following:

  • U: Move up (increase y-coordinate by 1).
  • D: Move down (decrease y-coordinate by 1).
  • L: Move left (decrease x-coordinate by 1).
  • R: Move right (increase x-coordinate by 1).

Your task is to compute the final coordinates \((x, y)\) of the robot after executing all commands. The final coordinates should be printed on a single line separated by a space.

inputFormat

The input consists of a single line containing a string of characters. Each character is one of 'U', 'D', 'L', or 'R', representing a command for the robot.

For example:

UURRDDLL

outputFormat

Output the final coordinates of the robot as two integers separated by a space.

For example:

0 0
## sample
UURRDDLL
0 0