sherlock and the beast problem