#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m, i, j, k, s, p, ct, ans, INF = 1E9;
  cin >> n >> m;
  vector<int> a(n), c(m + 1, 0);
  for (i = 0; i < n; i++) cin >> a[i];
  s = 0;
  for (i = 1; i <= m; i++) {
    cin >> c[i];
    s += c[i];
    c[i] = -c[i];
  }
  ct = m;
  ans = INF;
  for (i = 1; i <= m; i++) {
    if (c[i] == 0) ct--;
  }
  p = 0;
  for (i = 0; i < n; i++) {
    while ((p < n) && (ct > 0)) {
      c[a[p]]++;
      if (c[a[p]] == 0) ct--;
      p++;
    }
    if (ct == 0) ans = min(ans, p - i - s);
    c[a[i]]--;
    if (c[a[i]] < 0) ct++;
  }
  if (ans == INF) ans = -1;
  cout << ans << "\n";
  return 0;
}
