#include <bits/stdc++.h>
using namespace std;
struct FlowEdge {
  int v, u;
  long long cap, flow = 0;
  FlowEdge(int v, int u, long long cap) : v(v), u(u), cap(cap) {}
};
struct Dinic {
  const long long flow_inf = 1e18;
  vector<FlowEdge> edges;
  vector<vector<int>> adj;
  int n, m = 0;
  int s, t;
  vector<int> level, ptr;
  queue<int> q;
  Dinic(int n, int s, int t) : n(n), s(s), t(t) {
    adj.resize(n);
    level.resize(n);
    ptr.resize(n);
  }
  void add_edge(int v, int 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()) {
      int v = q.front();
      q.pop();
      for (int 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(int v, long long pushed) {
    if (pushed == 0) return 0;
    if (v == t) return pushed;
    for (int& cid = ptr[v]; cid < (int)adj[v].size(); cid++) {
      int id = adj[v][cid];
      int 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 flow() {
    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;
  }
};
void solve() {
  int n, m, x;
  cin >> n >> m;
  map<int, set<int>> div_index;
  vector<vector<int>> adj(n);
  vector<map<int, int>> cnt_index(n);
  for (int i = 0; i < n; i++) {
    cin >> x;
    for (int j = 2; j * j <= x; j++) {
      if (x % j) continue;
      int cnt = 0;
      while (x % j == 0) {
        x /= j;
        cnt++;
      }
      div_index[j].insert(i);
      cnt_index[i][j] = cnt;
    }
    if (x > 1) {
      div_index[x].insert(i);
      cnt_index[i][x] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for (auto& pset : div_index) {
    int prime = pset.first;
    int s = 0, t = n + 1;
    Dinic Network(n + 2, s, t);
    for (int index : div_index[prime]) {
      if (index & 1 ^ 1) {
        Network.add_edge(s, index + 1, cnt_index[index][prime]);
        for (int to : adj[index]) {
          if (div_index[prime].count(to)) {
            Network.add_edge(index + 1, to + 1, cnt_index[to][prime]);
          }
        }
      } else {
        Network.add_edge(index + 1, t, cnt_index[index][prime]);
      }
    }
    ans += Network.flow();
    ;
    ;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
