OK, I understand... Well, some STM32 may reach up to 72MHz (the worst case of 36MHz), it seems like it can handle a signal of 1.5MHz...
Anyway, you could also use the input capture mode, that is, you have a register which only increments when an input pin is at a desired state. So, when the signal is high, one register would increment (at the rate of the timer clock), while when low, another register would increment (you should use 2 intput pins of the STM32). This would solve the problem in the way you thought. But the problem of doing it in this way, is you may have problems like this:
HLHLHLHLLHLHLHHLHL
In the previous case, there are 2 low states, and 2 high states in the chain. So, you will finally have the same value in both registers, and you couldn't identify the change in phase case... Well, if you just have high states like in your previous example instead of several high and several low it could be useful.
Another possible solution: Do you have one single signal or two? If you have two, maybe you could use a quadrature decoder... Or if you just have one, you could generate another signal with 50% of duty cycle at the same frequency (1.5MHz) with a PWM peripheral, to add the second signal and to be able to use the quadrature decoder.