The oxidation number of an ion is the same as its charge. We know that the oxidation number of K+ is +1 and the oxidation number of O2- is -2, but we don't know the oxidation number of Mn so let's call that x. There are 2 K+ ions which makes +2 and 4 O2- ions which makes -8 (4*-2) and in K2MnO2 we know the charge of the molecule is neutral so the overall oxidation number must be 0. Therefore +2 (K) + x (Mn) + -8 (O) = 0 which means x = +6 so the oxidation number of Mn is +6 in K2MnO4.