Three solutions. Two by me, 1 by 9z.
Trivial using DP