Digital circuit to toggle on rising edge of two signals
You can do this with a D flip-flop with an asyncronous clear function







simulate this circuit &ndash; Schematic created using CircuitLab

Practically, you'll more often find the clear function has a low-active input, so you might need an inverter on your B signal.

For example, you could use 74AC11074.