Start the circuit when s is asserted while reset state A is active. Then examine w in non-overlapping groups of three clock cycles. Set z during the cycle after a group contains exactly two 1s; otherwise keep z low. Continue processing groups until reset.