Need some help with overflows and extremely large numbers.

For example, to calculate this:

(22 ^ 29) Mod 57

Supposedly there is a way to get around overflows and do these calculations, but I can't find much online. Now, the person who said this was doing VBA in Excel and said that there was about 4 lines of code which could handle the overflow so it wouldn't happen.

I can't figure out how, thought I would try a quick VB program, but even using the Decimal data type these numbers are just too large.

Any ideas? Thanks!