#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
int prime[100005], isprime[100005] = {0}, pcnt;
vector<int> fac[N];
vector<int> id[N];
vector<int> G[N];
long long a[N];
void findfac(long long x, vector<int>& fac) {
  for (int i = 0; i < pcnt && x > 1; ++i) {
    while (x % prime[i] == 0) {
      x /= prime[i];
      fac.push_back(prime[i]);
    }
  }
  if (x > 1) fac.push_back((int)x);
}
void add(int a, int b) {
  for (int i = 0; i < fac[a].size(); ++i) {
    int pos = (int)(lower_bound(fac[b].begin(), fac[b].end(), fac[a][i]) -
                    fac[b].begin());
    for (int j = pos; j < fac[b].size() && fac[b][j] == fac[a][i]; ++j) {
      G[id[a][i]].push_back(id[b][j]);
      G[id[b][j]].push_back(id[a][i]);
    }
  }
}
bool used[N];
int mac[N];
bool find(int x) {
  for (int i = 0; i < G[x].size(); ++i) {
    int v = G[x][i];
    if (!used[v]) {
      used[v] = 1;
      if (mac[v] == -1 || find(mac[v])) {
        mac[v] = x;
        return 1;
      }
    }
  }
  return 0;
}
void get_prime() {
  int N = 100005;
  pcnt = 0;
  for (int i = 2; i < N; ++i) {
    if (!isprime[i]) prime[pcnt++] = i;
    for (int j = 0; j < pcnt && i * prime[j] < N; ++j) {
      isprime[i * prime[j]] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
int main(int argc, const char* argv[]) {
  get_prime();
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", a + i);
    findfac(a[i], fac[i]);
  }
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < fac[i].size(); ++j) {
      id[i].push_back(++cnt);
    }
  }
  for (int u, v, i = 1; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    add(u, v);
  }
  memset(mac, -1, sizeof(mac));
  int ans = 0;
  for (int i = 1; i <= cnt; ++i) {
    memset(used, 0, sizeof(used));
    if (find(i)) ans++;
  }
  printf("%d\n", ans / 2);
  return 0;
}
