Iterate both the strings and count the number of occurrences of
for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { if ( s1 . charAt ( i ) == '0' ) { s1_0 ++ ; } if ( s2 . charAt ( i ) == '0' ) { s2_0 ++ ; } }