Counting the centralizers of some finite groups