Enumerating submodules invariant under an endomorphism