You're trying to print every single pulse, not every 40.
Each print statement prints 1-2 characters, which at 57600 bps takes 0.14 ms per character, or 0.28 ms for two characters, so your counting will work up to 3,500 Hz.
Double your port speed and you double the speed you can count at.
Remove that Serial.print(cont) statement and you can count up to about 500 kHz.