#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1005;
const int Maxm = 30005;
vector<pair<int, int> > f[Maxn];
vector<int> g[Maxm];
int linker[Maxm], tot;
bool vis[Maxm];
int dfs(int u) {
  for (int i = 0; i < g[u].size(); i++) {
    if (vis[g[u][i]]) continue;
    vis[g[u][i]] = 1;
    if (linker[g[u][i]] == -1 || dfs(linker[g[u][i]])) {
      linker[g[u][i]] = u;
      return 1;
    }
  }
  return 0;
}
int hungary() {
  int ans = 0;
  memset(linker, -1, sizeof linker);
  for (int i = 1; i <= tot; i++) {
    memset(vis, 0, sizeof vis);
    ans += dfs(i);
  }
  return ans;
}
int main() {
  int n, m, x;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    for (int j = 2; j * j <= x; j++) {
      while (x % j == 0) {
        f[i].push_back(pair<int, int>(j, ++tot));
        x /= j;
      }
    }
    if (x > 1) f[i].push_back(pair<int, int>(x, ++tot));
  }
  while (m--) {
    int i, j;
    scanf("%d%d", &i, &j);
    if (i & 1) swap(i, j);
    for (int u = 0; u < f[i].size(); u++)
      for (int v = 0; v < f[j].size(); v++) {
        if (f[i][u].first == f[j][v].first)
          g[f[i][u].second].push_back(f[j][v].second);
      }
  }
  printf("%d\n", hungary());
  return 0;
}
