More efficient way of counting the samples size.