#!/bin/bash

read N
read S
ANS=300000

E=`echo $S | fold -s1 | sort | uniq -c | awk '$2=="E"{print $1}'`

for i in `seq 1 $N`; do
        L=`echo $S | cut -b$i`
        [ "$L" = "E" ] && E=$((E-1))
        [ "$E" -lt "$ANS" ] && ANS=$E
        [ "$L" = "W" ] && E=$((E+1))
done

echo $ANS