Vehicular Adhoc NETworks (VANETs) is a new and emerging technology for wireless communications that has attracted considerable attention in the last years from the academic, scientific, industrial and governmental communities, due to the improvements and the new features that it brings to the Intelligent Transportation Systems (ITSs). In this paper, we present an algorithm that uses VANET technology to determine the total number of vehicles that are stopped at a traffic light at an intersection.To facilitate an efficient counting, we divide the road into fixed-size road regions and through a leader election mechanism, we designate one vehicle in each region as the ''Region Leader'' that is in charge of computing and propagating the total number of nodes in its region. Additionally, the region leader will act as a router to retransmit counting information from other region leaders that are further away, so it can eventually reach the central processing point where it is processed. We have carried out extensive experiments in various scenarios to validate and analyze the behavior and precision of our new proposed algorithm. Also, we compare our algorithm with another strategy proposed by a research team led by Alok Rajan. Our simulations were done using Veins (Vehicle in Network Simulation), an open-source simulation framework that ties together two simulators: OMNeT++ for the network simulation and SUMO for the microscopic road traffic simulation. Both simulators run in parallel and communicate with each other through a TCP connection using a protocol called TraCI (Traffic Control Interface). Our simulation results show that the algorithm performs an effective counting of vehicles, with a reduced response time, and a small total number of control messages sent by the vehicles to accomplish the counting task, under different conditions of vehicular traffic loads.