#include <bits/stdc++.h>
using namespace std;
int r, s, nes[200050], a[200050], col[200050], n, k, ans = 2147483647, tot;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &nes[i]);
    tot += nes[i];
    if (!nes[i]) s++;
  }
  if (s == k) {
    printf("0\n");
    return 0;
  }
  r = 1;
  while (nes[a[r]] == 0) ++r;
  for (int i = r; i <= n; i++) {
    col[a[i]]++;
    if (col[a[i]] == nes[a[i]] && nes[a[i]]) s++;
    if (col[a[i]] > nes[a[i]] && a[i] == a[r]) r++, col[a[i]]--;
    while (r <= n && col[a[r]] > nes[a[r]]) col[a[r]]--, r++;
    if (s == k) ans = std::min(i - r + 1 - tot, ans);
  }
  if (ans > 1e9)
    printf("-1\n");
  else
    printf("%d", ans);
}
