#include <bits/stdc++.h>
using namespace std;
struct pi {
  int to;
  int cost;
  int rev;
} pp;
vector<pi> g[3500];
queue<int> q;
int s, t;
int line[3500], leve[3500];
int min(int a, int b) {
  int p;
  p = a;
  if (b < a) p = b;
  return p;
}
void add(int a, int b, int cos) {
  pp.to = b;
  pp.cost = cos;
  pp.rev = (int)g[b].size();
  g[a].push_back(pp);
  pp.to = a;
  pp.cost = 0;
  pp.rev = (int)g[a].size() - 1;
  g[b].push_back(pp);
  return;
}
void bfs(void) {
  q.push(s);
  int p, f, i;
  while (!q.empty()) {
    p = q.front();
    q.pop();
    f = (int)g[p].size();
    for (i = 0; i < f; i++) {
      pi &e = g[p][i];
      if (e.cost > 0 && line[e.to] < 0) {
        line[e.to] = line[p] + 1;
        q.push(e.to);
      }
    }
  }
  return;
}
int dfs(int v, int f) {
  int p;
  if (v == t) return f;
  for (int &i = leve[v]; i < g[v].size(); i++) {
    pi &e = g[v][i];
    if (line[v] < line[e.to] && e.cost > 0) {
      p = dfs(e.to, min(f, e.cost));
      if (p > 0) {
        e.cost -= p;
        g[e.to][e.rev].cost += p;
        return p;
      }
    }
  }
  return 0;
}
int dinic() {
  int f;
  int flow = 0;
  while (1) {
    memset(line, -1, sizeof(line));
    memset(leve, 0, sizeof(leve));
    line[s] = 0;
    bfs();
    if (line[t] < 0) return flow;
    f = dfs(s, 100000000);
    if (f == 0) continue;
    flow += f;
    while ((f = dfs(s, 100000000)) > 0) {
      flow += f;
    }
  }
}
int a[105];
vector<int> gg[105];
int cc[105][50];
int nu[105];
int b[105][50];
int x[105][50];
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void get(int a, int p) {
  int i, j, k;
  k = a;
  for (i = 2; i * i <= k; i++) {
    j = 0;
    while (a % i == 0) {
      a = a / i;
      j++;
    }
    if (j > 0) {
      cc[p][nu[p]] = i;
      b[p][nu[p]] = j;
      nu[p]++;
    }
  }
  if (a > 1) {
    cc[p][nu[p]] = a;
    b[p][nu[p]] = 1;
    nu[p]++;
  }
}
int main() {
  int i, j, n, m, p, k, cnt, cn1;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  s = 0;
  t = 3202;
  cnt = 1;
  for (i = 1; i <= n; i++) {
    get(a[i], i);
    if (i % 2 == 0) {
      for (j = 0; j < nu[i]; j++) {
        add(s, cnt, b[i][j]);
        x[i][j] = cnt;
        cnt++;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (i % 2 != 0) {
      for (j = 0; j < nu[i]; j++) {
        add(cnt, t, b[i][j]);
        x[i][j] = cnt;
        cnt++;
      }
    }
  }
  cnt--;
  for (i = 0; i < m; i++) {
    scanf("%d%d", &k, &p);
    if (p % 2 == 0) swap(k, p);
    for (j = 0; j < nu[k]; j++) {
      for (int f = 0; f < nu[p]; f++) {
        if (cc[k][j] == cc[p][f]) {
          add(x[k][j], x[p][f], min(b[k][j], b[p][f]));
        }
      }
    }
  }
  printf("%d\n", dinic());
}
