The first step would be to detect the pulses and count them up.
A very simple solution would be to take all the points in the ECG above a threshold, then require that there is some minimum deadtime between heartbeats. You can get the number of pulse with something like:
sum(find(diff(find(x > threshold)) > deadtime))
This will be extremely sensitive to noise and artifacts. If this i homework, you likely want to use a filtering technique that you have covered (maybe a matched filter)