#K5136. Final Position of a Robot

    ID: 29070 Type: Default 1000ms 256MiB

Final Position of a Robot

Final Position of a Robot

You are given a string S that represents the movements of a robot on a 2D grid. Each character in the string corresponds to a movement:

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

The robot starts at the origin \( (0, 0) \). Your task is to compute its final position after performing all the movements in the given string.

Note: If the string is empty, the final position remains \( (0, 0) \).

inputFormat

Input is read from standard input (stdin). The input consists of a single line containing a non-empty string S which is composed of characters 'U', 'D', 'L', and 'R'.

outputFormat

Output the final coordinates of the robot as two integers separated by a space. For example, if the final position is ( (x, y) ), print "x y" (without quotes).## sample

UDLR
0 0