The input pulse can be up to 10KHz. The input is counted by counter/timer 1 of the chip so it counts even when the display refreshes. Counts can be up to millions when preset is limited to 999,999. One push-buttons advances the 6 digits of the preset and the other one selects the digit.
Input can be a solid state or a switch, a cap of 0.01 uF across the contact will reduce bounce. Input is set for pull-up to 5V so dry contact is connected from input 5 to GRD.
When count reach preset output at pin 13 goes high, this can be used for initiating a process or a LED indicator. If preset isn't needed then use the same sketch and don't fit push-buttons.