#K79697. Taco Grid Movement Score

    ID: 35366 Type: Default 1000ms 256MiB

Taco Grid Movement Score

Taco Grid Movement Score

You are given a string of commands representing the movements of a player on a 2D grid, starting at the origin (0,0). Each command moves the player one unit in a specified direction:

  • U for up
  • D for down
  • L for left
  • R for right

The score is the sum of the Manhattan distances between successive positions. The Manhattan distance between two points \( (x_0, y_0) \) and \( (x_1, y_1) \) is given by:

\( |x_1 - x_0| + |y_1 - y_0| \)

Your task is to compute and output the total score after executing all commands.

inputFormat

The input consists of a single line containing a non-empty string of commands made up solely of the characters U, D, L, and R. An empty input should be considered as no movement.

outputFormat

Output a single integer representing the total score, which is the sum of the Manhattan distances moved for each command.

## sample
URDL
4