public static String process ( TestCase testCase ) {
  final int N = testCase . N ;
  final String S = testCase . S ;
  if ( N <= 0 ) {
    return ZERO ;
  }
  else {
    final List < Direction > directions = Arrays . stream ( S . split ( "" ) ) . map ( Direction :: valueOf ) . collect ( Collectors . toList ( ) ) ;
    long min = IntStream . range ( 1 , N ) . mapToObj ( directions :: get ) . filter ( Direction . E :: equals ) . count ( ) ;
    long change = min ;
    for ( int i = 1 ;
    i < N ;
    ++ i ) {
      final Direction prev = directions . get ( i - 1 ) ;
      final Direction curr = directions . get ( i ) ;
      if ( Direction . W . equals ( prev ) ) {
        change ++ ;
      }
      if ( Direction . E . equals ( curr ) ) {
        change -- ;
      }
      min = Math . min ( min , change ) ;
    }
    return String . valueOf ( min ) ;
  }
}

public static String process ( TestCase testCase ) { final int N = testCase . N ; final String S = testCase . S ; if ( N <= 0 ) { return ZERO ; } else { final List < Direction > directions = Arrays . stream ( S . split ( " " ) ) . map ( Direction :: valueOf ) . collect ( Collectors . toList ( ) ) ; long min = IntStream . range ( 1 , N ) . mapToObj ( directions :: get ) . filter ( Direction . E :: equals ) . count ( ) ; long change = min ; for ( int i = 1 ; i < N ; ++ i ) { final Direction prev = directions . get ( i - 1 ) ; final Direction curr = directions . get ( i ) ; if ( Direction . W . equals ( prev ) ) { change ++ ; } if ( Direction . E . equals ( curr ) ) { change -- ; } min = Math . min ( min , change ) ; } return String . valueOf ( min ) ; } }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration (modifiers) type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration (modifiers) type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (identifier))) alternative: (block (local_variable_declaration (modifiers) type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal))))) name: (identifier) arguments: (argument_list (method_reference (identifier) (identifier)))) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) name: (identifier) arguments: (argument_list (method_reference (identifier) (identifier)))) name: (identifier) arguments: (argument_list (method_reference (field_access object: (identifier) field: (identifier)) (identifier)))) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration (modifiers) type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration (modifiers) type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (update_expression (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))))