#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
const int N = 102;
vector<vector<int>> cap(N, vector<int>(N, 0)), g(N);
int countDiv(int x) {
  int cnt = 0;
  int z = sqrt(x);
  for (int i = 2; i <= z; i++) {
    while (x % i == 0) {
      x /= i;
      cnt++;
    }
  }
  if (x > 2) cnt++;
  return cnt;
}
int bfs(int s, int t, vector<int>& p) {
  fill(p.begin(), p.end(), -1);
  p[s] = -2;
  queue<pair<int, int>> q;
  q.push({s, INT_MAX});
  while (!q.empty()) {
    int flow = q.front().second;
    int curr = q.front().first;
    q.pop();
    for (auto nxt : g[curr]) {
      if (p[nxt] == -1 && cap[curr][nxt]) {
        int new_flow = min(cap[curr][nxt], flow);
        p[nxt] = curr;
        q.push({nxt, new_flow});
        if (nxt == t) return new_flow;
      }
    }
  }
  return 0;
}
int maxFlow(int s, int t, int n) {
  int new_flow, flow = 0;
  vector<int> p(n);
  while (new_flow = bfs(s, t, p)) {
    int curr = t;
    while (curr != s) {
      cap[curr][p[curr]] += new_flow;
      cap[p[curr]][curr] -= new_flow;
      curr = p[curr];
    }
    flow += new_flow;
  }
  return flow;
}
set<int> sp;
void findPrimes(int x) {
  int z = sqrt(x);
  for (int i = 2; i <= z; i++) {
    if (x % i == 0) sp.insert(i);
    while (x % i == 0) x /= i;
  }
  if (x >= 2) sp.insert(x);
}
int countPower(int x, int p) {
  int cnt = 0;
  while (x % p == 0) {
    x /= p;
    cnt++;
  }
  return cnt;
}
void printG(int n) {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      cout << cap[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}
void solve() {
  int n, m, u, v, x;
  cin >> n >> m;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    findPrimes(a[i]);
  }
  vector<pair<int, int>> good_pairs;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    good_pairs.push_back({u, v});
    if (u & 1)
      cap[u][v] = INT_MAX;
    else
      cap[v][u] = INT_MAX;
  }
  int s = 0, t = n + 1;
  for (int i = 1; i <= n; i++) {
    if (i & 1)
      g[s].push_back(i);
    else
      g[i].push_back(t);
  }
  int res = 0;
  for (auto it : sp) {
    for (int i = s; i <= t; i++) {
      for (int j = s; j <= t; j++) cap[i][j] = cap[j][i] = 0;
    }
    for (auto it : good_pairs) {
      if ((it.first) & 1)
        cap[it.first][it.second] = INT_MAX;
      else
        cap[it.second][it.first] = INT_MAX;
    }
    for (int i = 1; i <= n; i++) {
      if (i & 1)
        cap[s][i] = countPower(a[i], it);
      else
        cap[i][t] = countPower(a[i], it);
    }
    res += maxFlow(s, t, n + 2);
  }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
