###### Description

Suppose that you want to move a game character by using 4 commands. The commands are as follows.

• U: Move upward by one space

• D: Move downward by one space

• R: Move rightward by one space

• L: Move leftward by one space

The character starts from the (0, 0) position on the coordinate plane. The border of the coordinate plane consists of the left top (-5, 5), left bottom (-5, -5), right top (5, 5), and right bottom (5, -5). For example, assume that you command to the character as "ULURRDLLU". • From the first through the 7-th command, the character moves as follows. • From the 8-th through the 9-th command, the character moves as follows. At this point, you want to know the length of the spaces where the character moves for the first time among the roads where the character passes. For example, in the above case, the character moved by the length of 9, but the length of spaces where the character moved for the first time is 7. (The spaces moved by the 8-th and the 9-th commands are already visited by the second and the third commands.)

But, the command moving over the border of the coordinate plane is ignored.

For example, assume that you command to the character as "LULLLLLLU". • The character moves according to the first through the 6-th command and ignores the 7-th and the 8-th commands. And then, the character moves according to the 9-th command. At this point, the length of spaces where the character moves for the first time is 7.

Given the commands `dirs` as parameter, write a function `solution` to return the length of spaces where the character moves for the first time.

##### Constraints
• `dirs` is given in the string format, and there is no character other than 'U', 'D', 'R', and 'L'.
• Length of `dirs` is natural number less than or equal to 500.
##### Examples
"ULURRDLLU" 7
"LULLLLLLU" 7

Example #1
This is the same with the example in the problem statement.

Example #2
This is the same with the example in the problem statement.

Result
Result of [Run Test] or [Submit] will be displayed here
내가 제출한 코드가 왜 틀렸는지 프로그래머스 AI에게 물어보세요.
제출 후 채점하기를 눌러 30점 이상인 경우 물어볼 수 있어요.
베타 기간 동안에는 한 문제당 1번만 물어볼 수 있어요.