All problems

Problem 497

Robot Return to Origin

Easy · 10 pts · String, Simulation

Problem

A robot starts at the origin (0, 0) of a 2D plane and follows a sequence of moves: U moves up one unit, D down, L left and R right. Decide whether the robot is back at the origin after all the moves. The robot returns exactly when the number of U moves equals the number of D moves and the number of L moves equals the number of R moves.

Input

A single string of the characters U, D, L and R.

Output

Print YES if the robot ends at the origin, otherwise NO.

Constraints

1 <= length <= 20000

Example input

UD

Example output

YES

Explanation

'UD' moves up one step and then down one step, so the robot is back at the origin: YES.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Image Smoother Next: Walking Robot Simulation