Integrals of motion of pure and mixed quantum systems