#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3fffffff;
const long long mod = 1000000007;
int a[110];
const int MAXN = 110;
const int MAXM = 1000;
const int INF = 0x3f3f3f3f;
struct Node {
  int from, to, next;
  int cap;
} edge[MAXM];
int tol;
int head[MAXN];
int dep[MAXN];
int gap[MAXN];
int n;
void addedge(int u, int v, int w) {
  edge[tol].from = u;
  edge[tol].to = v;
  edge[tol].cap = w;
  edge[tol].next = head[u];
  head[u] = tol++;
  edge[tol].from = v;
  edge[tol].to = u;
  edge[tol].cap = 0;
  edge[tol].next = head[v];
  head[v] = tol++;
}
void BFS(int start, int end) {
  memset(dep, -1, sizeof(dep));
  memset(gap, 0, sizeof(gap));
  gap[0] = 1;
  int que[MAXN];
  int front, rear;
  front = rear = 0;
  dep[end] = 0;
  que[rear++] = end;
  while (front != rear) {
    int u = que[front++];
    if (front == MAXN) front = 0;
    for (int i = head[u]; i != -1; i = edge[i].next) {
      int v = edge[i].to;
      if (dep[v] != -1) continue;
      que[rear++] = v;
      if (rear == MAXN) rear = 0;
      dep[v] = dep[u] + 1;
      ++gap[dep[v]];
    }
  }
}
int SAP(int start, int end) {
  int res = 0;
  BFS(start, end);
  int cur[MAXN];
  int S[MAXN];
  int top = 0;
  memcpy(cur, head, sizeof(head));
  int u = start;
  int i;
  while (dep[start] < n) {
    if (u == end) {
      int temp = INF;
      int inser;
      for (i = 0; i < top; i++)
        if (temp > edge[S[i]].cap) {
          temp = edge[S[i]].cap;
          inser = i;
        }
      for (i = 0; i < top; i++) {
        edge[S[i]].cap -= temp;
        edge[S[i] ^ 1].cap += temp;
      }
      res += temp;
      top = inser;
      u = edge[S[top]].from;
    }
    if (u != end && gap[dep[u] - 1] == 0) break;
    for (i = cur[u]; i != -1; i = edge[i].next)
      if (edge[i].cap != 0 && dep[u] == dep[edge[i].to] + 1) break;
    if (i != -1) {
      cur[u] = i;
      S[top++] = i;
      u = edge[i].to;
    } else {
      int min = n;
      for (i = head[u]; i != -1; i = edge[i].next) {
        if (edge[i].cap == 0) continue;
        if (min > dep[edge[i].to]) {
          min = dep[edge[i].to];
          cur[u] = i;
        }
      }
      --gap[dep[u]];
      dep[u] = min + 1;
      ++gap[dep[u]];
      if (u != start) u = edge[S[--top]].from;
    }
  }
  return res;
}
vector<int> V;
pair<int, int> q[110];
int main() {
  int n1, m;
  scanf("%d%d", &n1, &m);
  for (int i = 1; i < n1 + 1; i++) scanf("%d", &a[i]);
  int st = 0, ed = n1 + 1;
  n = ed + 1;
  for (int i = 1; i < m + 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a & 1)
      q[i] = make_pair(a, b);
    else
      q[i] = make_pair(b, a);
  }
  V.clear();
  for (int i = 1; i < n1 + 1; i++) {
    int t = a[i];
    for (int j = 2; j * j <= t && t; j++) {
      if (t % j == 0) {
        V.push_back(j);
        while (t % j == 0 && t) t /= j;
      }
    }
    if (t && t != 1) V.push_back(t);
  }
  sort(V.begin(), V.end());
  V.erase(unique(V.begin(), V.end()), V.end());
  int ans = 0;
  for (int i = 0; i < V.size(); i++) {
    tol = 0;
    for (int i = st; i < ed + 1; i++) head[i] = -1;
    for (int j = 1; j < n1 + 1; j++) {
      int cnt = 0;
      int t = a[j];
      while (t % V[i] == 0 && t) {
        t /= V[i];
        cnt++;
      }
      if (j & 1)
        addedge(st, j, cnt);
      else
        addedge(j, ed, cnt);
    }
    for (int i = 1; i < m + 1; i++) {
      addedge(q[i].first, q[i].second, inf);
    }
    ans += SAP(st, ed);
  }
  printf("%d\n", ans);
  return 0;
}
