#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v[2];
vector<vector<int> > g;
bool w[200][200];
bool vis[100000];
int link[100000];
bool match(int x) {
  for (int i = 0; i < g[x].size(); i++) {
    int v = g[x][i];
    if (!vis[v]) {
      vis[v] = 1;
      if (link[v] == -1 || match(link[v])) {
        link[v] = x;
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  int a;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    for (int j = 2; j * j <= a; j++) {
      if (a % j == 0) {
        while (a % j == 0) {
          v[i % 2].push_back(make_pair(i, j));
          a /= j;
        }
      }
    }
    if (a > 1) v[i % 2].push_back(make_pair(i, a));
  }
  int b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    w[a][b] = w[b][a] = 1;
  }
  g.resize(v[0].size());
  for (int i = 0; i < v[0].size(); i++) {
    for (int j = 0; j < v[1].size(); j++) {
      if (w[v[0][i].first][v[1][j].first]) {
        if (v[0][i].second == v[1][j].second) g[i].push_back(j);
      }
    }
  }
  memset(link, -1, sizeof(link));
  int ans = 0;
  for (int i = 0; i < v[0].size(); i++) {
    memset(vis, 0, sizeof(vis));
    if (match(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}
