Problem1878--CF748 - C. Santa Claus and Robot

1878: CF748 - C. Santa Claus and Robot

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

Santa Claus has Robot which lives on the infinite grid and can movealong its lines. He can also, having a sequence of $m$ points $p_1,p_2,...,p_m$ with integer coordinates, do the following: denote its initial location by $p_0$. First, the robot will move from $p_0$ to $p_1$ along one of the shortest paths between them (please notice that since the robot moves only along the grid lines, there can be several shortest paths). Then, after it reaches $p_1$, it'll move to $p_2$, again, choosing one of the shortest ways, then to $p_3$, and so on, until he has visited all points in the given order. Some of the points in the sequence may coincide, in that case Robot will visit that point several times according to the sequence order.
While Santa was away, someone gave a sequence of points to Robot. This sequence is now lost, but Robot saved the protocol of its unit movements. Please, find the minimum possible length of the sequence.

Input

The first line of input contains the only positive integer $n\ (1≤n≤2·10^5)$ which equals the number of unit segments the robot traveled. 
The second line contains the movements protocol, which consists of $n$ letters, each being equal either L, or R, or U, or D. $k$-th letter stands for the direction which Robot traveled the $k$-th unit segment in:L means that it moved to the left, R− to the right, U− to the top and D− to the bottom. Have a look at the illustrations for better explanation.

Output

The only line of input should contain the minimum possible length of the sequence.

Sample 1 Input

4
RURD

Sample 1 Output

2

Sample 2 Input

6
RRULDD

Sample 2 Output

2

Sample 3 Input

26
RRRULURURUULULLLDLDDRDRDLD

Sample 3 Output

7

3
RLL

2

Sample 4 Input

4
LRLR

Sample 4 Output

4

HINT

相同题目:CF748C

Source/Category