object Main extends App {
	val n = scala.io.StdIn.readInt
	var s = scala.io.StdIn.readLine.toList.map{case 'W' => 1; case 'E' => 0}

	var a = 0
	var b = n - s.sum
	var ans = n

	for(x <- s){
		if(x == 1){
			ans = math.min(ans, a + b)
			a += 1
		}else{
			b -= 1
			ans = math.min(ans, a + b)
		}
	}

	println(ans)
	
}