The boolean function Y=AB+CD is to be realized using only 2-input NAND gates. The minimum number of gates required is