#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> edges[4000], match(4000);
vector<pair<int, int> > occ(4000, make_pair(-1, -1));
vector<vector<int> > let;
vector<bool> visited(4000);
int dfs(int id) {
  visited[id] = 1;
  for (int v : edges[id]) {
    if (!visited[v] && match[v] == v) {
      match[v] = id;
      match[id] = v;
      return 1;
    }
    if (!visited[v] && !visited[match[v]] && match[v] != id) {
      if (dfs(match[v])) {
        match[id] = v;
        match[v] = id;
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int u, v;
  cin >> n >> m;
  iota(match.begin(), match.end(), 0);
  let.resize(n, vector<int>(n, 0));
  int dex = 0;
  for (int i = 0; i < n; i++) {
    cin >> u;
    for (int j = 2; j * j <= u; j++) {
      while (u % j == 0) {
        occ[dex++] = make_pair(i, j);
        u /= j;
      }
    }
    if (u != 1) {
      occ[dex++] = make_pair(i, u);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    u--;
    v--;
    let[u][v] = 1;
    let[v][u] = 1;
  }
  for (int i = 0; i < 4000; i++) {
    if (occ[i] != make_pair(-1, -1)) {
      for (int j = 0; j < 4000; j++) {
        if (occ[j] == make_pair(-1, -1)) continue;
        if (occ[i].second == occ[j].second && let[occ[i].first][occ[j].first]) {
          edges[i].push_back(j);
        }
      }
    }
  }
  int res = 0;
  for (int i = 0; i < 4000; i++) {
    visited.assign(4000, 0);
    if (match[i] == i) {
      res += dfs(i);
    }
  }
  cout << res << endl;
}
