Dependence of multiplicity on primary energy in nucleon-nucleon and pion-nucleon collisions