This pertains to economics but that's largely irrelevant as I'm having trouble with the math. The utility function, in this case person A's, is being maximized.
Production function of x: $$ x=f\left(y_{s}^{A}+y_{s}^{B}\right) $$
Two 'utility' functions for person A and B: $$ U^{A}\left(x, y^{A *}-y_{s}^{A}\right) $$ $$ U^{B}\left(x, y^{B *}-y_{s}^{B}\right) $$ Lagrangian: $$ \mathscr{L}=U^{A}\left(x, y^{A *}-y_{s}^{A}\right)+\lambda\left[U^{B}\left(x, y^{B *}-y_{s}^{B}\right)-K\right] $$
First-order conditions is where I get lost and do not understand: $$ \begin{array}{l}{\frac{\partial \mathscr{L}}{\partial y_{s}^{A}}=U_{1}^{A} f^{\prime}-U_{2}^{A}+\lambda U_{1}^{B} f^{\prime}=0} \\ {\frac{\partial \mathscr{L}}{\partial y_{s}^{B}}=U_{1}^{A} f^{\prime}-\lambda U_{2}^{B}+\lambda U_{1}^{B} f^{\prime}=0}\end{array} $$
Mathematically I do not follow how the first-order conditions come about from the provided Lagrangian. Just looking at the top equation, $ \frac{\partial \mathscr{L}}{\partial y_{s}^{A}}$, where do these three components come from when differentiating with respect to $ y_{S}^{A} $?