If you use PIC then it has internal EEPROM which can be used to store the data. Your data can be 1 byte, 2 byte or 4 byte depending upon char, int or long the counter value. So, you may need 1, 2 or 4 bytes of EEPROM. You can also store data in Flash ROM. For that you can use Flash read/write routines which comes with some Compilers. Interface the o/p of limit switch to T0CKI pin or INTx pin of PIC and use interrupts to increment the counter whenever there is a trigger. At frequent duration of time you can save this counter value to Flash ROM or Internal EEPROM. Provide your circuit and I will help in a mikroC Code.