#include <bits/stdc++.h>
using namespace std;
long long n, m, a[105], sx, sy, res, dx[100005], dy[100005];
map<pair<long long, long long>, long long> ok;
vector<long long> ke[100005];
bool ck[100005];
pair<long long, long long> x[100005], y[100005];
bool fin(long long u) {
  if (ck[u]) return false;
  ck[u] = true;
  for (auto v : ke[u]) {
    if (dy[v] == 0 || fin(dy[v])) {
      dy[v] = u;
      dx[u] = v;
      return true;
    }
  }
  return false;
}
void Solve() {
  cin >> n >> m;
  for (long long id = 1, _b = n; id <= _b; id++) {
    cin >> a[id];
    for (long long i = 2; i <= sqrt(a[id]); i++) {
      while (a[id] % i == 0) {
        if (id & 1)
          x[++sx] = {i, id};
        else
          y[++sy] = {i, id};
        a[id] /= i;
      }
    }
    if (a[id] > 1) {
      if (id & 1)
        x[++sx] = {a[id], id};
      else
        y[++sy] = {a[id], id};
    }
  }
  for (long long i = 1, _b = m; i <= _b; i++) {
    long long u, v;
    cin >> u >> v;
    ok[{u, v}] = ok[{v, u}] = 1;
  }
  for (long long i = 1, _b = sx; i <= _b; i++)
    for (long long j = 1, _b = sy; j <= _b; j++) {
      if (ok[{x[i].second, y[j].second}] && x[i].first == y[j].first)
        ke[i].push_back(j);
    }
  for (long long i = 1, _b = sx; i <= _b; i++) {
    for (long long j = 1, _b = sx; j <= _b; j++) ck[j] = false;
    if (fin(i)) res++;
  }
  cout << res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int Test_numbers = 1;
  while (Test_numbers--) Solve();
  return 0;
}
