#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) {
  return n | (1LL << i);
  ;
}
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) { return modPow(a, 1000000007 - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
bool seive[1010000];
vector<int> prime;
void seiveGen(int limit) {
  limit += 100;
  int sqrtn = sqrt(limit);
  for (int i = 3; i <= sqrtn; i += 2) {
    if (!seive[i >> 1]) {
      for (int j = i * i; j < limit; j += i + i) {
        seive[j >> 1] = 1;
      }
    }
  }
  prime.emplace_back(2);
  for (int i = 3; i < limit; i += 2) {
    if (!seive[i >> 1]) prime.emplace_back(i);
  }
}
const int MX = 110;
map<int, int> store[110];
int yo[3200], graph[3200][3200], vis[3200], par[3200], vnum = 1;
void factorise(int idx, int num) {
  int sqrtn = sqrt(num);
  for (int i = 0; prime[i] <= sqrtn; ++i) {
    if (num % prime[i] == 0) {
      int cnt = 0;
      while (num % prime[i] == 0) ++cnt, num /= prime[i];
      store[idx][prime[i]] = vnum;
      yo[vnum++] = cnt;
    }
  }
  if (num > 1) {
    store[idx][num] = vnum;
    yo[vnum++] = 1;
  }
}
int maxflow() {
  int flow = 0;
  while (1) {
    ;
    int s = 0;
    memset(vis, 0, sizeof(vis));
    memset(par, 0, sizeof(par));
    queue<int> bfs;
    bfs.push(0);
    vis[0] = true;
    while (!bfs.empty() && !vis[vnum]) {
      int u = bfs.front();
      bfs.pop();
      ;
      for (int i = 0; i <= vnum; ++i) {
        if (!vis[i] && graph[u][i] > 0) {
          par[i] = u;
          vis[i] = true;
          bfs.push(i);
        }
      }
    }
    if (!vis[vnum]) break;
    int cur = vnum, mcost = inf;
    while (cur != 0) {
      ;
      mcost = min(mcost, graph[par[cur]][cur]);
      cur = par[cur];
    }
    cur = vnum;
    while (cur != 0) {
      graph[par[cur]][cur] -= mcost;
      graph[cur][par[cur]] += mcost;
      cur = par[cur];
    }
    flow += mcost;
  }
  return flow;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  seiveGen(sqrt(1e9) + 10);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    int num;
    cin >> num;
    factorise(i, num);
  }
  for (int i = 1; i <= n; ++i) {
    ;
    for (auto it : store[i]) {
      ;
      if (i & 1)
        graph[0][it.second] = yo[it.second];
      else
        graph[it.second][vnum] = yo[it.second];
    }
  }
  for (int i = 0; i < m; ++i) {
    ;
    int u, v;
    cin >> u >> v;
    if (v & 1) swap(u, v);
    for (auto it : store[u]) {
      if (!store[v].count(it.first)) continue;
      graph[it.second][store[v][it.first]] =
          min(yo[it.second], yo[store[v][it.first]]);
    }
  }
  for (int i = 0; i <= vnum; ++i) {
    for (int j = 0; j <= vnum; ++j) {
      if (graph[i][j])
        ;
    }
  };
  cout << maxflow();
  return 0;
}
