I'll tell u a shortcut for these types of problems:
We know that, Acceleration of the masses= Net Pulling force , right
Total mass
So what is the net pulling force= (M-m)g
what is total mass=M+m+(no of pulleys)/r2
So substituting we get ,
a=(M-m)g / (m+M+2I/r2)
This works for all types of these problems, see hcv from 30-40 all will work.
This is in a way a valid method as we have to account for the mass of pulley which we do by the I/r2 term