If $L(q,\dot{q},t)$ is a lagrangian of a system, then $L' = L + \frac{dF(q,t)}{dt}$ is also a valid lagrangian and both lagrangians will lead to the same equation of motion.
But, what if I choose $F(q,t)$ such that $L'=0$? \begin{equation} L + \frac{dF}{dt} = 0 \\ F = - \int{L dt} = -S \end{equation} where $S$ is the action.
Is this valid? If yes, can we not do this always? What does it mean?