Counting Function of Characteristic Values and Magnetic Resonances