Complete countAbc function