#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1000;
const int MAXM = 20500;
struct Node {
  int from, to, next;
  int cap;
} edge[MAXM];
int tol;
int dep[MAXN];
int head[MAXN];
void init() {
  tol = 0;
  memset(head, -1, sizeof(head));
}
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++;
}
int BFS(int start, int end) {
  int que[MAXN];
  int front, rear;
  front = rear = 0;
  memset(dep, -1, sizeof(dep));
  que[rear++] = start;
  dep[start] = 0;
  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 (edge[i].cap > 0 && dep[v] == -1) {
        dep[v] = dep[u] + 1;
        que[rear++] = v;
        if (rear >= MAXN) rear = 0;
        if (v == end) return 1;
      }
    }
  }
  return 0;
}
int dinic(int start, int end) {
  int res = 0;
  int top;
  int stack[MAXN];
  int cur[MAXN];
  while (BFS(start, end)) {
    memcpy(cur, head, sizeof(head));
    int u = start;
    top = 0;
    while (1) {
      if (u == end) {
        int min = INF;
        int loc;
        for (int i = 0; i < top; i++)
          if (min > edge[stack[i]].cap) {
            min = edge[stack[i]].cap;
            loc = i;
          }
        for (int i = 0; i < top; i++) {
          edge[stack[i]].cap -= min;
          edge[stack[i] ^ 1].cap += min;
        }
        res += min;
        top = loc;
        u = edge[stack[top]].from;
      }
      for (int i = cur[u]; i != -1; cur[u] = i = edge[i].next)
        if (edge[i].cap != 0 && dep[u] + 1 == dep[edge[i].to]) break;
      if (cur[u] != -1) {
        stack[top++] = cur[u];
        u = edge[cur[u]].to;
      } else {
        if (top == 0) break;
        dep[u] = -1;
        u = edge[stack[--top]].from;
      }
    }
  }
  return res;
}
int n, m, a[105], x[105], y[105], h[105];
int slove(int num) {
  int i, j;
  init();
  memset(h, 0, sizeof(h));
  for (i = 1; i <= n; i++) {
    int tmp = a[i];
    while (tmp % num == 0) tmp /= num, h[i]++;
  }
  int start = 0, end = n + 1;
  for (i = 1; i <= n; i++) {
    if (i & 1)
      addedge(start, i, h[i]);
    else
      addedge(i, end, h[i]);
  }
  for (i = 1; i <= m; i++) {
    if (x[i] % 2 == 1)
      addedge(x[i], y[i], INF);
    else
      addedge(y[i], x[i], INF);
  }
  return dinic(start, end);
}
int main() {
  init();
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x[i], &y[i]);
  }
  int i, j;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int key = a[i];
    for (int k = 2; key > 1;) {
      if (key % k == 0) {
        s.insert(k);
        for (; key % k == 0; key /= k)
          ;
      }
      if (k == 2)
        k++;
      else
        k += 2;
      if (k * k > key) k = key;
    }
  }
  int ans = 0;
  for (set<int>::iterator it = s.begin(); it != s.end(); ++it) {
    int key = *it;
    if (key == 0) continue;
    ans += slove(key);
  }
  cout << ans << endl;
  return 0;
}
