Cryptographic transformations with a secret key play an essential role in providing information and cyber security. Block and stream symmetric ciphers are used in various applications both as a separate cryptographic protection mechanism and as part of other applications (pseudo-random sequence generators, hashing algorithms, electronic signature protocols, etc.). Therefore, the design and study of individual components of symmetric ciphers is a relevant and important scientific task. In this paper we consider and investigates iterative algorithms for generating non-linear substitutions (substitutions, S-boxes), which are used in modern block and stream encryption algorithms with a symmetric key. Cryptographic resistance of symmetric ciphers to statistical, differential, linear and other methods of cryptanalysis is provided by the properties of substitutions. In addition, S-boxes must be random from the point of view of the possibility to use algebraic cryptanalysis. Therefore, the task of quickly generating random S-boxes with the desired cryptographic properties is an urgent, but extremely difficult task. For example, the best known generation algorithm requires more than 65 thousand iterations to find a random bijective 8-bit substitution with a non-linearity of 104. In this paper, we study an iterative algorithm for generating substitutions for hill climbing with different cost functions and propose a new cost function, the use of which can significantly reduce the number of search iterations. In particular, the search for a bijective S-box with nonlinearity 104 requires less than 50 thousand iterations.