Make sure you're not attempting to actually convert the numbers to ints. Python can handle 30000-bit integers, but not nearly fast enough for this problem.
Avoid creating lots of large objects if you can help it. In particular, slicing a list or string involves copying the entirety of the slice, so you shouldn't be taking large slices of anything in a loop.