Nonlinear resonance and stochasticity in intramolecular energy exchange