Hackerrank.com Sherlock and the Beast Python2