In statistics, the amount of degrees of freedom is the quantity of values in the final computation of a statistic that are free to differ. In this case, you can get the answer by adding the number of bags and subtracting 1.
So in computation, this would look like: 3 + 2 + 1 + 2 - 1 = 7
Therefore, 7 is the degrees of freedom.