Endre has many nieces and nephews. Once a year he takes some of them on a trip to an archipelago, where a boat company runs two way services between some pairs of islands. Endre and the children can fly directly in and out of any island, so a trip is a nonempty sequence of islands i1,i2,…,in in which consecutive islands ij and ij+1 are joined by a boat service. The first and the last island may be the same or different, and an island may be visited more than once.
Every island makes its own kind of candy and gives each arriving group a fixed number of pieces. Endre does not eat candy, but the children finish theirs at once. To keep the peace, every time the group lands on an island and receives candy he splits it evenly among the children. If he brings k children, the candy count of every island the trip visits must be divisible by k.
The travel agency sends him the trip plan, the sequence i1,i2,…,in, in advance. He wants to bring as many of the children as possible, so he works out the largest number k of children he can bring without breaking the even split rule. He brings at least one child. Each trip plan fixes exactly one number of children.
Over the years the number of children has been different every time. Endre wants to know how many group sizes are possible. Count the integers k such that some trip plan makes him bring exactly k children.
The first line contains two integers I and S (1≤I,S≤104), the number of islands and the number of boat services. Islands are numbered with distinct integers from 1 to I.
The second line contains I integers C1,C2,…,CI, where Ci is the number of pieces of candy the group receives on island i (1≤Ci≤105).
Each of the next S lines contains two integers A and B (1≤A<B≤I) describing one boat service, which runs from island A to island B and from island B to island A. No pair of islands is joined by more than one service.
Print one line with the number of integers k such that some trip plan makes Endre bring exactly k children.