Make sure download the library for Arduino DUE board before you upload the code. It can be done by click the board manager and download the SAM3x board. This code can count pulse which last at least 20ns. It also allows you to change the gate rate without reprogramme the board.