#include <bits/stdc++.h>
using namespace std;
struct FlowEdge {
  long long v, u;
  long long cap, flow = 0;
  FlowEdge(long long v, long long u, long long cap) : v(v), u(u), cap(cap) {}
};
const long long flow_inf = 1e18;
struct Dinic {
  vector<FlowEdge> edges;
  vector<vector<long long>> adj;
  long long n, m = 0;
  long long s, t;
  vector<long long> level, ptr;
  queue<long long> q;
  Dinic(long long n, long long s, long long t) : n(n), s(s), t(t) {
    adj.resize(n + 1);
    level.resize(n + 1);
    ptr.resize(n + 1);
  }
  void add_edge(long long v, long long u, long long cap) {
    edges.emplace_back(v, u, cap);
    edges.emplace_back(u, v, 0);
    adj[v].push_back(m);
    adj[u].push_back(m + 1);
    m += 2;
  }
  bool bfs() {
    while (!q.empty()) {
      long long v = q.front();
      q.pop();
      for (long long id : adj[v]) {
        if (edges[id].cap - edges[id].flow < 1) continue;
        if (level[edges[id].u] != -1) continue;
        level[edges[id].u] = level[v] + 1;
        q.push(edges[id].u);
      }
    }
    return level[t] != -1;
  }
  long long dfs(long long v, long long pushed) {
    if (pushed == 0) return 0;
    if (v == t) return pushed;
    for (long long &cid = ptr[v]; cid < (long long)adj[v].size(); cid++) {
      long long id = adj[v][cid];
      long long u = edges[id].u;
      if (level[v] + 1 != level[u] || edges[id].cap - edges[id].flow < 1)
        continue;
      long long tr = dfs(u, min(pushed, edges[id].cap - edges[id].flow));
      if (tr == 0) continue;
      edges[id].flow += tr;
      edges[id ^ 1].flow -= tr;
      return tr;
    }
    return 0;
  }
  long long maxflow() {
    long long f = 0;
    while (true) {
      fill(level.begin(), level.end(), -1);
      level[s] = 0;
      q.push(s);
      if (!bfs()) break;
      fill(ptr.begin(), ptr.end(), 0);
      while (long long pushed = dfs(s, flow_inf)) {
        f += pushed;
      }
    }
    return f;
  }
};
set<long long> primes;
void go(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      primes.insert(i);
      while (n % i == 0) n /= i;
    }
  }
  if (n > 1) primes.insert(n);
  return;
}
long long go2(long long n, long long p) {
  long long res = 0;
  while (n % p == 0) {
    n /= p;
    res++;
  }
  return res;
}
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n + 1);
  for (long long i = 1; i <= n; i++) cin >> a[i], go(a[i]);
  vector<pair<long long, long long>> pairs(m);
  for (long long i = 0; i < m; i++) {
    cin >> pairs[i].first >> pairs[i].second;
    if ((pairs[i].second & 1)) swap(pairs[i].first, pairs[i].second);
  }
  long long ans = 0;
  for (auto &p : primes) {
    long long src = 0;
    long long dest = n + 1;
    Dinic dinic(n + 2, src, dest);
    for (long long i = 1; i <= n; i++) {
      long long cnt = go2(a[i], p);
      if (i & 1)
        dinic.add_edge(src, i, cnt);
      else
        dinic.add_edge(i, dest, cnt);
    }
    for (auto &u : pairs) dinic.add_edge(u.first, u.second, flow_inf);
    ans += dinic.maxflow();
  }
  cout << ans;
}
