#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
const int maxn = 3200;
const int maxm = 105;
vector<int> adj[maxn];
vector<pair<long long int, long long int> > num[maxm];
int mark[maxn];
int match[maxn];
int A[maxm];
int id = 1;
int cnt;
bool dfs(int v) {
  mark[v] = 1;
  for (int u : adj[v]) {
    if (match[u] == 0 || (!mark[match[u]] && dfs(match[u]))) {
      match[u] = v;
      match[v] = u;
      return true;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    for (int j = 2; j * j <= A[i]; j++) {
      while (A[i] % j == 0) {
        A[i] /= j;
        num[i].push_back({j, id});
        id++;
      }
    }
    if (A[i] > 1) {
      num[i].push_back({A[i], id});
      id++;
    }
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    int pos = 0;
    for (pair<long long int, long long int> P : num[u]) {
      while (pos < num[v].size() && num[v][pos].first < P.first) pos++;
      for (int i = pos; i < num[v].size() && num[v][i].first == P.first; i++) {
        adj[P.second].push_back(num[v][i].second);
        adj[num[v][i].second].push_back(P.second);
      }
    }
  }
  for (int i = 1; i <= n; i += 2) {
    for (pair<long long int, long long int> P : num[i]) {
      fill(mark, mark + maxn, 0);
      if (!match[P.second]) {
        if (dfs(P.second)) cnt++;
      }
    }
  }
  cout << cnt;
  return 0;
}
