The one way to do it is to do the following:
Let's assume that the optical sensor consist of two parts, transmitter and receiver, transmitter constantly sends a beam of light (or whatever) towards the receiver, hence receiver gets all the energy, let's assume that this state is logical "1".Once the object is in the between, no energy gets to a receiver, hence the output is at low state, logical "0".
The only thing you're required to do is to count those 1->0 or 0->1 (you'll have to decide) transitions, in order to get the number of objects that has passed. A simple counter implemented using flip-flops could be used, where the output is fed directly to some BCD display via appropriate logic. You can find discrete implementations of the counters searching the
http://focus.ti.com/paramsearch/doc...&navigationId=11385&family=logic¶mTable=" or Analog Devices sites.
Now, the output of receiver is not perfect, since it is a sensor, so the output won't have those perfect 0's and 1's, hence the output of the sensor should be coupled with a comparator opamp, this way you'll be able to sort out between 0's & 1's better (distinguish level transitions).
Since you didn't mention anything about the number of objects, I'm guessing that there will be a finite number of them, so when you've determined the number of objects so you can find out what kind of counter you'll need (how many bits). Otherwise, when you don't know anything about the number of objects, you'll need a micro controller of some kind in order to save and add the number of objects, before resetting the counter.