Simple DP. Learned a new way to handle large input.