Topological characteristics of the spectrum of the Schrödinger operator in a magnetic field and in a weak potential