added a function which returns the total number of elements in a sequence