Lagrangian dynamics by nonlocal constants of motion