The figure shows a circuit with three inputs A, B and C. Gate 1 is a NAND gate for A and B. Gate 2 is a NOR gate for B and C. Gate 3 is an XOR gate that takes the outputs of gates 1 and 2, and its output is Y. For how many of the eight input patterns is Y=1?