compute number of elements