The process of magnetization of the system of a finite number N of plane domain walls in a right-angled specimen is investigated by computing. The topology of the system allows only three types of behaviour of the domain structure depending on the parity of N and on the direction of the magnetization in the domains located at the edges of a specimen. The first type is accompanied only by one structural phase transition N --> 0 at the field of saturation H(s), the other types have one more intermediate transition (N --> N-2 or N --> N-1) at H < H(s). The universal graph of the succession of the phase transitions is drawn which is independent of the material constants and of the ratio of the specimen size. Energy barriers between metastable states, in which the system is in the intervals between the phase transition, are calculated.