Trick/insight to I implement given boolean function with minimum numbers of given gate
There is no trick.  There is no efficient method.  The circuit minimization problem is NP-hard (in fact $\Sigma_2^P$-hard), and I suspect that finding the smallest circuit with only NAND gates is NP-hard, too.  That should tell you that there is no systematic approach that always works and is reasonably efficient.  Instead, you will have to use heuristics and trial-and-error.  For instance, you might have to try multiple methods and take the best circuit you can find among all of them.