Section 17A. Whoever, for the purpose of soliciting any alms, contribution or subscription or of selling any merchandise, except newspapers, or ticket of admission to any game, show, exhibition, fair, ball, entertainment or public gathering, signals a moving vehicle on any public way or causes the stopping of a vehicle thereon, or accosts any occupant of a vehicle stopped thereon at the direction of a police officer or signal man, or of a signal or device for regulating traffic, shall be punished by a fine of not more than fifty dollars. Whoever sells or offers for sale any item except newspapers within the limits of a state highway boundary without a permit issued by the department shall for the first offense be punished by a fine of fifty dollars and for each subsequent offense shall be punished by a fine of one hundred dollars. Notwithstanding the provisions of the first sentence of this section, on any city or town way which is not under jurisdiction of the department, the chief of police of a city or town may issue a permit to nonprofit organizations to solicit on said ways in conformity with the rules and regulations established by the police department of said city or town.