import java.util.*;enum M{M;System z;{for(Scanner s=new Scanner(z.in);z==z;){String[]a=s.next().split("\\^");long l=0;for(int i=0,j=a.length;i<j;)l^=new java.math.BigInteger(a[i++]).pow(i<j?new Integer(a[i++]):1).longValue();z.out.println(l);}}}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).