A topological invariant for the accessibility problem of micromagnetics