#K62722. Final Position of a Robot

    ID: 31595 Type: Default 1000ms 256MiB

Final Position of a Robot

Final Position of a Robot

A robot is initially positioned at the origin \((0, 0)\) on a Cartesian plane. It moves according to a sequence of commands provided as a string, where each character represents a direction:

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

Your task is to determine the final coordinates \((x, y)\) of the robot after executing all the commands. For instance, if the command sequence is UUDDLR, then the final position will be \((0, 0)\), as the moves cancel each other out.

inputFormat

The input consists of a single line containing a string of characters. Each character will be one of: U, D, L, or R.

outputFormat

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

## sample
UUDDLR
0 0