Function to return the count of required strings
static int countStr ( int i , String s ) { if ( i < 0 ) { if ( check ( s ) ) return 1 ; return 0 ; } char [ ] myNameChars = s . toCharArray ( ) ; myNameChars [ i ] = '0' ; s = String . valueOf ( myNameChars ) ; int ans = countStr ( i - 1 , s ) ; char [ ] myChar = s . toCharArray ( ) ; myChar [ i ] = '1' ; s = String . valueOf ( myChar ) ; ans += countStr ( i - 1 , s ) ; char [ ] myChar1 = s . toCharArray ( ) ; myChar1 [ i ] = '0' ; s = String . valueOf ( myChar1 ) ; return ans ; }