Circuit to convert 24VAC digital signal to 5V DC digital signal
Figure 1. R4 is redundant as R1, R3, Q1 and R2 shunt it.

Similarly in the second scheme R1 is redundant.







simulate this circuit &ndash; Schematic created using CircuitLab

Figure 2. Solution with component count of 2.

If you use a bi-directional opto-isolator and series resistor you can cut the component count to two. The opto-isolator output transistor will pull low every half-cycle if you use the MCU internal pull-up resistor. Your software will need a timer to check that AC has been lost for 10 ms or so before determining that AC is off. 

I have written more on opto-isolators here.