Under construction

Still being built. Things may change

Figurines

Interview

Time limit2sMemory limit1024 MB

Summary
Given n figurines each facing N, S, W, or E, find the fewest turns needed to make all of them face the same direction.
Level

Easy2 of 10

Topics
String, Implementation
Solved
No attempts yet

Statement

Nolik got into trouble again. This time he messed up Dim Dimych's collection of figurines. Dim Dimych cares a lot about these figurines, so he would be very upset to see them in such a mess. Simka decided to fix everything quickly.

After Nolik played with the figurines, each one was standing on a shelf facing one of four directions: north, south, west, or east. To fix the situation, Simka decided to turn some of the figurines so that all of them face the same direction. In one second, Simka can change the direction of one figurine. Help Simka find the minimum time she needs to make all figurines face the same direction.

Input

The first line contains the number of figurines nn (1≤n≤1051 \le n \le 10^5). The second line contains a string of length nn that gives the directions of the figurines. Each character is N, S, W, or E.

Output

Print the minimum time Simka needs to make all figurines face the same direction.

Examples1

  1. Example 1

    Input
    7
    NSNEWNN
    
    Expected output
    3