fun main(args:Array<String>){
	val n = readLine()!!.toInt()
	val s = readLine()!!
	
	val e=s.count { it=='E' }
	var cost = if(s.first()=='W') e else e-1
	var minCost= cost

	for(i in 1 until n){
		if(s[i]=='E') cost--
		if(s[i-1]=='W') cost++
		minCost=Math.min(minCost,cost)
	}
	println(minCost)
}