#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll mod = 1e9 + 7;
const int inf = 5e6;
const int INF = 1e9;
struct Edge {
  int from, to, cap, flow, index;
  Edge(int from, int to, int cap, int flow, int index)
      : from(from), to(to), cap(cap), flow(flow), index(index) {}
};
struct Dinic {
  int N;
  vector<vector<Edge> > G;
  vector<Edge *> dad;
  vector<int> Q;
  Dinic(int N) : N(N), G(N), dad(N), Q(N) {}
  void add_edge(int from, int to, int cap) {
    G[from].push_back(Edge(from, to, cap, 0, G[to].size()));
    if (from == to) G[from].back().index++;
    G[to].push_back(Edge(to, from, 0, 0, G[from].size() - 1));
  }
  long long blocking_flow(int s, int t) {
    fill(dad.begin(), dad.end(), (Edge *)NULL);
    dad[s] = &G[0][0] - 1;
    int head = 0, tail = 0;
    Q[tail++] = s;
    while (head < tail) {
      int x = Q[head++];
      for (int i = 0; i < G[x].size(); i++) {
        Edge &e = G[x][i];
        if (!dad[e.to] && e.cap - e.flow > 0) {
          dad[e.to] = &G[x][i];
          Q[tail++] = e.to;
        }
      }
    }
    if (!dad[t]) return 0;
    long long totflow = 0;
    for (int i = 0; i < G[t].size(); i++) {
      Edge *start = &G[G[t][i].to][G[t][i].index];
      int amt = INF;
      for (Edge *e = start; amt && e != dad[s]; e = dad[e->from]) {
        if (!e) {
          amt = 0;
          break;
        }
        amt = min(amt, e->cap - e->flow);
      }
      if (amt == 0) continue;
      for (Edge *e = start; amt && e != dad[s]; e = dad[e->from]) {
        e->flow += amt;
        G[e->to][e->index].flow -= amt;
      }
      totflow += amt;
    }
    return totflow;
  }
  long long max_flow(int s, int t) {
    long long totflow = 0;
    while (long long flow = blocking_flow(s, t)) totflow += flow;
    return totflow;
  }
  void clear_flow() {
    for (int i = 0; i < N; ++i)
      for (int j = 0; j < G[i].size(); ++j) G[i][j].flow = 0;
  }
};
const int sz = 5e4 + 10;
int n, m;
vector<int> G[105];
int src, sink;
int tot_v;
vector<int> pr;
bitset<sz> fl;
int fac[sz];
void siv() {
  for (int i = 4; i < sz; i += 2) fl[i] = 1;
  for (int i = 3; i * i < sz; i += 2) {
    if (fl[i]) continue;
    for (int j = i * i; j < sz; j += i) fl[j] = 1;
  }
  pr.push_back(2);
  for (int i = 3; i < sz; i += 2)
    if (fl[i] == 0) pr.push_back(i);
}
void factorise(int i, int num) {
  for (const int x : pr) {
    while (num % x == 0) {
      num /= x;
      tot_v++;
      G[i].push_back(tot_v);
      fac[tot_v] = x;
    }
  }
  if (num > 1) {
    tot_v++;
    G[i].push_back(tot_v);
    fac[tot_v] = num;
  }
}
int main() {
  siv();
  while (cin >> n >> m) {
    tot_v = 0;
    for (int i = 0; i < n; i++) {
      G[i].clear();
      int x;
      cin >> x;
      factorise(i, x);
    }
    src = 0;
    sink = tot_v + 1;
    Dinic graph(sink + 1);
    while (m--) {
      int x, y;
      cin >> x >> y;
      --x, --y;
      if (x & 1) swap(x, y);
      for (const int &u : G[x]) {
        for (const int &v : G[y]) {
          if (fac[u] == fac[v]) graph.add_edge(u, v, 1);
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (const int &u : G[i])
        graph.add_edge(i & 1 ? u : src, i & 1 ? sink : u, 1);
    }
    cout << graph.max_flow(src, sink) << "\n";
    cerr << "-----\n";
  }
  return 0;
}
