#include <bits/stdc++.h>   using namespace std;   int n, m, k = 0, cl[105 * 35], link[105 * 35];   vector<int> g[105 * 35];   vector<pair<int, int> > has[105];   bool dfs(int u) {     for (int i = 0; i < g[u].size(); ++i) {       int v = g[u][i];       if (!cl[v]) {         cl[v] = 1;         if (link[v] == 0 || dfs(link[v]) == true) {           link[v] = u;           return true;         }       }     }     return false;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       int x;       cin >> x;       for (int j = 2; j <= sqrt(x); ++j) {         if (x % j == 0) {           while (x % j == 0) {             x = x / j;             has[i].push_back({j, ++k});           }         }       }       if (x > 1) has[i].push_back({x, ++k});     }     for (int i = 1; i <= m; ++i) {       int u, v;       cin >> u >> v;       if (u % 2 == 0) swap(u, v);       for (int j = 0; j < has[u].size(); ++j)         for (int q = 0; q < has[v].size(); ++q) {           if (has[u][j].first == has[v][q].first) {             g[has[u][j].second].push_back(has[v][q].second);           }         }     }     int rs = 0;     for (int j = 1; j <= k; ++j) {       for (int i = 1; i <= k; ++i) cl[i] = 0;       if (dfs(j)) ++rs;     }     cout << rs;     return 0;   }   