#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void swap(T& a, U& b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
inline void swap(int& a, int& b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
inline void swap(long long& a, long long& b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
template <typename T, typename U>
inline void smax(T& a, U b) {
  if (b > a) a = b;
}
template <typename T, typename U>
inline void smin(T& a, U b) {
  if (b < a) a = b;
}
inline int gcd(int a, int b) {
  if (a < b) swap(a, b);
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
inline long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long nchose(int a, int b) {
  long long ans = 1;
  smax(a, b - a);
  int p = 2;
  for (int i = (b - a + 1); i <= (b); i++) {
    ans *= (long long)i;
    while (p <= a && ans % p == 0) ans /= p++;
  }
  return ans;
}
static long long MOD = 1000000007;
int n, m, b[102][102], c[102], src = 100, snk = 101, ans = 0, gac = 1;
bool a[102][102];
vector<int> v;
int dfs(int v, int p, int key) {
  if (p == snk) return v;
  if (c[p] == key) return 0;
  c[p] = key;
  int t = 0;
  for (int i = (snk); i >= (0); i--) {
    if (b[p][i] && (t = dfs(min(v, b[p][i]), i, key))) {
      b[p][i] -= t;
      b[i][p] += t;
      return t;
    }
  }
  return 0;
}
int pairs(int prime) {
  int flow = 0, t, ac;
  memset(b, 0, sizeof(int) * 52 * 52);
  for (int i = (0); i < (n); i++) {
    ac = 0;
    int t = v[i];
    while (t % prime == 0) t /= prime, ac++;
    if (i % 2 == 0) {
      b[i][snk] = ac;
    } else {
      b[src][i] = ac;
      for (int j = (0); j < (n); j++) {
        if (a[i][j]) {
          b[i][j] = ac;
        }
      }
    }
  }
  while ((t = dfs(999999, src, gac++)) > 0) flow += t;
  return flow;
}
set<int> primes;
int main() {
  cin >> n >> m;
  v.resize(n);
  for (int& i : v) cin >> i;
  while (m--) {
    int x, y;
    cin >> x >> y;
    ;
    x--, y--;
    if (x % 2 == 0) swap(x, y);
    a[x][y] = 1;
  }
  for (int i : v) {
    for (int p = 2; p * p <= i; p++) {
      if (i % p == 0) {
        primes.insert(p);
        while (i % p == 0) i /= p;
      }
    }
    if (i > 1) primes.insert(i);
  }
  for (int prime : primes) {
    ans += pairs(prime);
  }
  cout << ans;
}
