#include <bits/stdc++.h>
using namespace std;
const int maxnode = 110050;
const int maxedge = 500050;
const int oo = 1000000000;
int node, src, dest, nedge;
int head[maxnode], point[maxedge], nt[maxedge], flow[maxedge], capa[maxedge];
int dist[maxnode], Q[maxnode], work[maxnode];
void init(int _node, int _src, int _dest) {
  node = _node;
  src = _src;
  dest = _dest;
  for (int i = 0; i < node; i++) head[i] = -1;
  nedge = 0;
}
void add(int u, int v) {
  point[nedge] = v, capa[nedge] = 1, flow[nedge] = 0, nt[nedge] = head[u],
  head[u] = (nedge++);
  point[nedge] = u, capa[nedge] = 0, flow[nedge] = 0, nt[nedge] = head[v],
  head[v] = (nedge++);
}
bool dinic_bfs() {
  memset(dist, 255, sizeof(dist));
  dist[src] = 0;
  int sizeQ = 0;
  Q[sizeQ++] = src;
  for (int cl = 0; cl < sizeQ; cl++)
    for (int k = Q[cl], i = head[k]; i >= 0; i = nt[i])
      if (flow[i] < capa[i] && dist[point[i]] < 0) {
        dist[point[i]] = dist[k] + 1;
        Q[sizeQ++] = point[i];
      }
  return dist[dest] >= 0;
}
int dinic_dfs(int x, int exp) {
  if (x == dest) return exp;
  for (int &i = work[x]; i >= 0; i = nt[i]) {
    int v = point[i], tmp;
    if (flow[i] < capa[i] && dist[v] == dist[x] + 1 &&
        (tmp = dinic_dfs(v, min(exp, capa[i] - flow[i]))) > 0) {
      flow[i] += tmp;
      flow[i ^ 1] -= tmp;
      return tmp;
    }
  }
  return 0;
}
int maxFlow() {
  int result = 0;
  while (dinic_bfs()) {
    for (int i = 0; i < node; i++) work[i] = head[i];
    while (1) {
      int delta = dinic_dfs(src, oo);
      if (delta == 0) break;
      result += delta;
    }
  }
  return result;
}
vector<int> child[110];
vector<int> factor[110];
int arr[110];
int main() {
  init(10000, 0, 1);
  int n, m;
  cin >> n >> m;
  int counter = 2;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    for (int j = 2; j * j <= x; j++) {
      while (x % j == 0) {
        if ((i + 1) % 2 == 0)
          add(counter, 1);
        else
          add(0, counter);
        child[i + 1].push_back(counter++);
        factor[i + 1].push_back(j);
        x /= j;
      }
    }
    if (x > 1) {
      if ((i + 1) % 2 == 0)
        add(counter, 1);
      else
        add(0, counter);
      child[i + 1].push_back(counter++);
      factor[i + 1].push_back(x);
    }
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (x % 2 == 0) swap(x, y);
    for (int k = 0; k < factor[x].size(); k++) {
      for (int j = 0; j < factor[y].size(); j++) {
        if (factor[x][k] == factor[y][j]) {
          add(child[x][k], child[y][j]);
        }
      }
    }
  }
  cout << maxFlow();
  return 0;
}
