What ever you do, you should square up those sine waves being sent to the GPIO DIGITAL pins and clip off the negative cycle before trying a code.
Me, I use ESP32's and, in this case, would use, after squaring up the signals, the PCNT for pulse counting.