We present an algorithm for the generalized search problem (searching k marked items among N items) based on a continuous Hamiltonian and exploiting resonance. This resonant algorithm has the same time complexity O(N/k) <i as the Grover algorithm. A natural extension of the algorithm, incorporating auxiliary monitor qubits, can determine k precisely, if it is unknown. The time complexity of our counting algorithm is O(N) <i, similar to the best quantum approximate counting algorithm, or better, given appropriate physical resources.