code: public static long count_filtered(nitro_service service, String filter) throws Exception{
  		service obj = new service();
  		options option = new options();
  		option.set_count(true);
  		option.set_filter(filter);
  		service[] response = (service[]) obj.getfiltered(service, option);
  		if (response != null) {
  			return response[0].__count;
  		}
  		return 0;
  	}
docs: Use this API to count filtered the set of service resources.
  filter string should be in JSON format.eg: "port:80,servicetype:HTTP".