This article investigates the evolution of autonomous agents that perform a memory-dependent counting task. Two types of neurocontrollers are evolved: networks of McCulloch-Pitts neurons, and spiking integrate-and-fire networks. The results demonstrate the superiority of the spiky model in evolutionary success and network simplicity. The combination of spiking dynamics with incremental evolution leads to the successful evolution of agents counting over very long periods. Analysis of the evolved networks unravels the counting mechanism and demonstrates how the spiking dynamics are utilized. Using new measures of spikiness we find that even in agents with spiking dynamics, these are usually truly utilized only when they are really needed, that is, in the evolved subnetwork responsible for counting.