Construction of Free Body Diagrams of the Trolleys and resolving the forces (Weight and Tension) components acting parallel to the ramp (assuming friction and air resistance are negligible) show that for Trolley A: F=ma--> (M+2m)a=(M+2m)gsin35-T and for Trolley B: F=ma-->Ma=T-Mg. Note that the magnitude of acceleration a is identical for both trolleys but acceleration acts in opposite directions (assuming pulley is massless and frictionless) Rearranging the equations in terms of T gives T(Trolley A)=(M+2m)gsin35-(M+2m)a and T(Trolley B)=Ma+Mgsin35. Tension is the same throughout the whole wire (assuming light inextinsible wire) so combining the T equations gives (M+2m)gsin35-Mgsin35=Ma+(M+2m)a. Factorising both sides with (gsin35) and (a) accordingly and simplifying results in gsin35(~~M~~+2m-~~M~~)=a(M+M+2m) --> ~~2~~mgsin35=~~2~~a(M+m). Finally rearranging for a gives the solution which is a=(mgsin35)/(M+m)