The local cyclicity problem: Melnikov method using Lyapunov constants