The problem of an Artificial Neural Network (ANN) structure optimization is related to the definition of the optimal number of hidden layers and the distribution of neurons between layers depending on a selected optimization criterion and inflicted constrains. Using a hierarchical structure is an accepted default way of defining an ANN structure. The following article presents the resolution of the optimization problem. The function describing the number of subspaces is given, and the minimum number of layers, as well as the distribution of neurons between layers, shall be found. The structure can be described using different methods, mathematical tools, and software or/and technical implementation. The ANN decomposition into hidden and output layers - the first step to build a two-level learning algorithm for cross-forward connections structure - is described, too.