Complete strCount algorithm