If there is only 1 character which does not balances then also it is Yes
else if ( po == 1 && ne == 0 ) cout << ( " YES " ) << endl ; else if ( po == 0 && ne == -1 ) cout << ( " YES " ) << endl ; else cout < < ( " NO " ) << endl ; }