I often read,that if the lagrangian $L=p\dot{q}-H$ of a pair of coordinates in phase space $(q,p)$ and $P\dot{Q}- K $, for some new pair of coordinates $(Q,P)$ only differ by a total time derivative $dF/dt$, the Variation of the action functional doesn't differ too, which implies that the canonical equations for the new coordinates hold.
My question now is: if the action functional $S(q,p,t)=S'(Q,P,t) + c$ where $c= \int (dF/dt )dt $ is the integrated total time derivative of $F$ (which disappears in the Variation); why then is the variation of both sides equal? I mean surely the Variation of the $(q,p)$ coordinates would be the same for both sides, but why should the Variation of the $(Q,P)$ coordinates on the right hand side be the same as the Variation of the $(q,p)$ coordinates on the left hand side?