import java.io.PrintStream; import java.util.Arrays; import java.util.Scanner; /** * Solution to Stones of Yin & Yang * * @author vanb */ public class yinyang_vanb { private static Scanner sc; private static PrintStream ps; /** * Do it! */ private void doit() { char stones[] = sc.next().toCharArray(); // The trick is very simple: It's possible iff there's the same number of Black stones as White stones. // // Suppose B=W. Then pick one White stone. All the others form a group with one fewer // white stone than black stones, and thus can be reduced to a single black stone. And, you're done. // // Now suppose B!=W. Each operation always removes the same number of W stones as B stones. // So, you can never erase the difference. int w=0, b=0; for( char stone : stones ) { if( stone=='B' ) ++b; else if( stone=='W' ) ++w; else System.err.println( "PANIC!! Sonething other than B or W in input: " + stone ); } ps.println( b==w ? 1 : 0 ); } /** * main * * @param args * @throws Exception */ public static void main( String[] args ) throws Exception { sc = new Scanner( System.in ); ps = System.out; new yinyang_vanb().doit(); } }