Add count function.