Problem11416--AOI2021 - Robot Vacuum

11416: AOI2021 - Robot Vacuum

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

Description

Irene has a robot vacuum cleaner that automatically cleans her floor. Each day, the robot performs the same sequence of $K$ instructions.
There are four possible instructions, each represented by an uppercase character. Each instruc tion moves the robot one step in one of the four cardinal directions:
  • N - the robot moves one step north (↑).
  • E - the robot moves one step east (→).
  • S - the robot moves one step south (↓).
  • W - the robot moves one step west (←).
After the sequence of $K$ instructions, the robot is supposed to finish where it started, but the original programmers were a little bit rushed.
Irene has asked for your programming help. What is the smallest number of instructions needed to add to the end of the sequence so that the robot finishes where it started?

Input

The first line of input contains the single integer $K$.
The second line of input contains a string of $K$ characters, the sequence of instructions.

Output

Your program should output a single integer, the fewest instructions you need to add to the end of the sequence.

Constraints

$1\leq K \leq 10^5$

Sample 1 Input

5
ENNEE

Sample 1 Output

5

Sample 2 Input

7
EEWWWWE

Sample 2 Output

1

Sample 3 Input

8
SWWNENNS

Sample 3 Output

2

4
NESW

0

HINT

Source/Category