#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG = 20;
int n, m, k, u, v, x, y, t, a, b, ans, cnt;
int A[MAXN];
int match[MAXN];
bool col[MAXN];
vector<int> G[MAXN], good_pair[MAXN];
vector<pair<int, int> > taj[MAXN];
bitset<MAXN> mark;
bool dfs(int node) {
  if (mark[node]) return 0;
  mark.set(node);
  for (int v : G[node])
    if (!match[v] || dfs(match[v])) {
      match[v] = node;
      match[node] = v;
      return 1;
    }
  return 0;
}
int f(int x) {
  for (int i = 1; i <= n; i++)
    for (pair<int, int> p : taj[i])
      if (p.second == x) return i;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    for (int d = 2; d * d <= A[i]; d++)
      while (A[i] % d == 0) {
        taj[i].push_back({d, ++cnt});
        col[cnt] = i & 1;
        A[i] /= d;
      }
    if (A[i] > 1) taj[i].push_back({A[i], ++cnt}), col[cnt] = i & 1;
  }
  while (m--) {
    cin >> u >> v;
    for (pair<int, int> p1 : taj[u])
      for (pair<int, int> p2 : taj[v])
        if (p1.first == p2.first) {
          G[p1.second].push_back(p2.second);
          G[p2.second].push_back(p1.second);
        }
  }
  int flag = 1;
  while (flag--) {
    mark.reset();
    for (int i = 1; i <= cnt; i++)
      if (col[i] && !match[i]) flag |= dfs(i);
  }
  for (int i = 1; i <= cnt; i++)
    if (col[i] && match[i]) ans++;
  cout << ans << '\n';
  return 0;
}
