#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = 55000;
int a[MAXN], g[MAXN], ans, las = 1;
map<int, int> pri;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int Check(int x) {
  int rnt = 0;
  for (int i = 2; i * i <= x; ++i) {
    while (x % i == 0) {
      if (pri[i])
        rnt--;
      else
        rnt++;
      x /= i;
    }
  }
  if (x > 1)
    if (pri[x])
      rnt--;
    else
      rnt++;
  return rnt;
}
int main() {
  int n = read(), m = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  g[1] = a[1];
  for (int i = 1, j; i <= m; ++i) {
    j = read();
    pri[j] = 1;
  }
  for (int i = 2; i <= n; ++i) g[i] = gcd(g[i - 1], a[i]);
  for (int i = n; i >= 1; --i) {
    int p = g[i];
    if (Check(g[i]) < 0)
      for (int j = 1; j <= i; ++j) a[j] /= p, g[j] /= p;
  }
  for (int i = 1; i <= n; ++i) ans += Check(a[i]);
  printf("%d", ans);
  return 0;
}
