Counting pulses with Arduino Nano

GiovannyS10:
If i remove the Serial.print(cont) How will i see the cont value? How will i know when it reach 40?

Your code already checks for this reaching 40. There is no need or any practical use to try and print it out that fast - you can't read that fast, you can't react that fast to stop it, whatever. Just don't, it doesn't make sense.
When it reaches 40 you get into that if block, that's where you may print out the value of cont (if you don't believe it to be 40), and then wait a second before you start counting again.