#!/bin/bash

read N
read S
ANS=300000

for i in `seq 1 $N`; do
        S_W=`echo $S | cut -b1-$((i-1)) 2>/dev/null`
        S_E=`echo $S | cut -b$((i+1))- 2>/dev/null`
        C_W=`echo $S_W | fold -s1 | sort | uniq -c | awk '$2=="W"{print $1}'`
        C_E=`echo $S_E | fold -s1 | sort | uniq -c | awk '$2=="E"{print $1}'`
        RES=$((C_W+C_E))
        [ "$RES" -lt "$ANS" ] && ANS=$RES
done

echo $ANS