You have written on a piece of paper an array of *n* positive integers *a*[1], *a*[2], ..., *a*[*n*] and *m* good pairs of integers (*i*<sub class="lower-index">1</sub>, *j*<sub class="lower-index">1</sub>), (*i*<sub class="lower-index">2</sub>, *j*<sub class="lower-index">2</sub>), ..., (*i*<sub class="lower-index">*m*</sub>, *j*<sub class="lower-index">*m*</sub>). Each good pair (*i*<sub class="lower-index">*k*</sub>, *j*<sub class="lower-index">*k*</sub>) meets the following conditions: *i*<sub class="lower-index">*k*</sub> + *j*<sub class="lower-index">*k*</sub> is an odd number and 1 ≤ *i*<sub class="lower-index">*k*</sub> &lt; *j*<sub class="lower-index">*k*</sub> ≤ *n*.

In one operation you can perform a sequence of actions: 
 -  take one of the good pairs (*i*<sub class="lower-index">*k*</sub>, *j*<sub class="lower-index">*k*</sub>) and some integer *v* (*v* &gt; 1), which divides both numbers *a*[*i*<sub class="lower-index">*k*</sub>] and *a*[*j*<sub class="lower-index">*k*</sub>]; -  divide both numbers by *v*, i. e. perform the assignments: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/192b5056ddf57cd3030615790d2a21051c01bc9d.png" style="max-width: 100.0%;max-height: 100.0%;"/> and <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/f143c28d601c34862d9b5035284c5bde440a0e3d.png" style="max-width: 100.0%;max-height: 100.0%;"/>. 
Determine the maximum number of operations you can sequentially perform on the given array. Note that one pair may be used several times in the described operations.
The first line contains two space-separated integers *n*, *m* (2 ≤ *n* ≤ 100, 1 ≤ *m* ≤ 100).

The second line contains *n* space-separated integers *a*[1], *a*[2], ..., *a*[*n*] (1 ≤ *a*[*i*] ≤ 10<sup class="upper-index">9</sup>) — the description of the array.

The following *m* lines contain the description of good pairs. The *k*-th line contains two space-separated integers *i*<sub class="lower-index">*k*</sub>, *j*<sub class="lower-index">*k*</sub> (1 ≤ *i*<sub class="lower-index">*k*</sub> &lt; *j*<sub class="lower-index">*k*</sub> ≤ *n*, *i*<sub class="lower-index">*k*</sub> + *j*<sub class="lower-index">*k*</sub> is an odd number).

It is guaranteed that all the good pairs are distinct.
"""
Codeforces Contest 284 Div 1 Problem C

Author  : chaotic_iak
Language: Python 3.4.2
"""

################################################### SOLUTION

def main():
    n,m = read()
    a = read()
    pairs = [read() for _ in range(m)]
    for i in range(m):
        if pairs[i][0] % 2:
            pairs[i] = (pairs[i][0], pairs[i][1])
        else:
            pairs[i] = (pairs[i][1], pairs[i][0])

    res = 0
    for i in primes():
        if i > 100000: break
        p = [0] * n
        for j in range(n):
            while a[j] % i == 0:
                a[j] //= i
                p[j] += 1
        net = FlowNetwork()
        for j in range(n+2): net.add_vertex(j)
        for j in range(0, n, 2): net.add_edge(0, j+1, p[j])
        for j in range(1, n, 2): net.add_edge(j+1, n+1, p[j])
        for j,k in pairs: net.add_edge(j, k, 1000)
        res += net.max_flow(0, n+1)

    for i in range(0, n, 2):
        for j in range(1, n, 2):
            if (i+1, j+1) in pairs and a[i] == a[j] != 1:
                a[i] = 1
                a[j] = 1
                res += 1
    print(res)

#################################################### HELPERS

# Taken from pyprimes module by Steven d'Aprano (https://pypi.python.org/pypi/pyprimes/0.1.1a)
# Renamed croft to primes
def primes():
    import itertools
    for p in (2, 3, 5):
        yield p
    roots = {9: 3, 25: 5}
    primeroots = frozenset((1, 7, 11, 13, 17, 19, 23, 29))
    selectors = (1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0)
    for q in itertools.compress(
            itertools.islice(itertools.count(7), 0, None, 2),
            itertools.cycle(selectors)
            ):
        if q in roots:
            p = roots[q]
            del roots[q]
            x = q + 2*p
            while x in roots or (x % 30) not in primeroots:
                x += 2*p
            roots[x] = p
        else:
            roots[q*q] = q
            yield q


# Ford-Fulkerson
# Wikipedia is neat
class Edge(object):
    def __init__(self, u, v, w):
        self.source = u
        self.sink = v
        self.capacity = w
    def __repr__(self):
        return "%s->%s:%s" % (self.source, self.sink, self.capacity)

class FlowNetwork(object):
    def __init__(self):
        self.adj = {}
        self.flow = {}

    def add_vertex(self, vertex):
        self.adj[vertex] = []

    def get_edges(self, v):
        return self.adj[v]

    def add_edge(self, u, v, w=0):
        if u == v:
            raise ValueError("u == v")
        edge = Edge(u,v,w)
        redge = Edge(v,u,0)
        edge.redge = redge
        redge.redge = edge
        self.adj[u].append(edge)
        self.adj[v].append(redge)
        self.flow[edge] = 0
        self.flow[redge] = 0

    def find_path(self, source, sink, path):
        if source == sink:
            return path
        for edge in self.get_edges(source):
            residual = edge.capacity - self.flow[edge]
            if residual > 0 and edge not in path:
                result = self.find_path( edge.sink, sink, path + [edge])
                if result is not None:
                    return result

    def max_flow(self, source, sink):
        path = self.find_path(source, sink, [])
        while path is not None:
            residuals = [edge.capacity - self.flow[edge] for edge in path]
            flow = min(residuals)
            for edge in path:
                self.flow[edge] += flow
                self.flow[edge.redge] -= flow
            path = self.find_path(source, sink, [])
        return sum(self.flow[edge] for edge in self.get_edges(source))


def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0: return inputs
    if mode == 1: return inputs.split()
    if mode == 2: return list(map(int, inputs.split()))

def write(s="\n"):
    if s is None: s = ""
    if isinstance(s, list): s = " ".join(map(str, s))
    s = str(s)
    print(s, end="")

write(main())