Part two is a dynamic programming problem. Starting with 1 copy of each card we add the extra number of copies to the number of following cards equal to the number of winning numbers.