n = 0 Count of North s = 0 Count of South e = 0 Count of East w = 0 Count of West
for i in range ( length ) : NEW_LINE INDENT if ( st [ i ] == " N " ) : NEW_LINE INDENT n += 1 NEW_LINE DEDENT if ( st [ i ] == " S " ) : NEW_LINE INDENT s += 1 NEW_LINE DEDENT if ( st [ i ] == " W " ) : NEW_LINE INDENT w += 1 NEW_LINE DEDENT if ( st [ i ] == " E " ) : NEW_LINE INDENT e += 1 NEW_LINE DEDENT DEDENT if ( n == s and w == e ) : NEW_LINE INDENT print ( " YES " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT