Solved easy problem: Basic Dynamic Programming, Modular Arithmetic