First attemt of DP, but doesn't count repetitions either