Counting pulses with Arduino Nano

I have a function generator. I want to read it, and after every 40 pulses i want to stop it for one second. Just it. But it must be precisely 40 pulses.