Even distribution

No attempts yetTime limit3sMemory limit256 MB

Problem

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,,ini_1, i_2, \dots, i_n in which consecutive islands iji_j and ij+1i_{j+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 kk children, the candy count of every island the trip visits must be divisible by kk.

The travel agency sends him the trip plan, the sequence i1,i2,,ini_1, i_2, \dots, i_n, in advance. He wants to bring as many of the children as possible, so he works out the largest number kk 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 kk such that some trip plan makes him bring exactly kk children.

Input

The first line contains two integers II and SS (1I,S1041 \le I, S \le 10^4), the number of islands and the number of boat services. Islands are numbered with distinct integers from 11 to II.

The second line contains II integers C1,C2,,CIC_1, C_2, \dots, C_I, where CiC_i is the number of pieces of candy the group receives on island ii (1Ci1051 \le C_i \le 10^5).

Each of the next SS lines contains two integers AA and BB (1A<BI1 \le A < B \le I) describing one boat service, which runs from island AA to island BB and from island BB to island AA. No pair of islands is joined by more than one service.

Output

Print one line with the number of integers kk such that some trip plan makes Endre bring exactly kk children.