#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int c[n];
  for (int(i) = 0; (i) < (n); ++(i)) cin >> c[i], --c[i];
  int k[m];
  for (int(i) = 0; (i) < (m); ++(i)) cin >> k[i];
  vector<int> f(m, 0);
  int sol = n + 1, ok = 0, qtd = 0;
  for (int i = 0; i < m; ++i)
    if (k[i] == 0) ++ok;
  for (int i = 0, j = 0; j < n; ++j) {
    ++f[c[j]];
    if (f[c[j]] > k[c[j]]) ++qtd;
    if (f[c[j]] == k[c[j]]) ++ok;
    while (i < j && f[c[i]] > k[c[i]]) {
      --f[c[i]];
      --qtd;
      if (f[c[i]] == k[c[i]] - 1) --ok;
      ++i;
    }
    if (ok == m) sol = min(sol, qtd);
  }
  cout << (sol == n + 1 ? -1 : sol) << endl;
  return 0;
}
