#include <bits/stdc++.h>
int a[200005], c[200005], k[200005];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", k + i);
  }
  for (int i = 0; i <= m; ++i) {
    c[i] = 0;
  }
  int left = 0, right = -1;
  int numOk = 0;
  for (int i = 1; i <= m; ++i) {
    if (k[i] == 0) numOk++;
  }
  int diff = 0;
  int minDiff = 200005;
  while (right < n) {
    while (numOk < m && right < n) {
      right++;
      c[a[right]]++;
      if (c[a[right]] == k[a[right]]) {
        numOk++;
      } else if (c[a[right]] > k[a[right]]) {
        diff++;
      }
    }
    while (c[a[left]] > k[a[left]]) {
      c[a[left]]--;
      diff--;
      left++;
    }
    if (diff < minDiff && numOk == m) minDiff = diff;
    c[a[left]]--;
    numOk--;
    left++;
  }
  printf("%d\n", (minDiff != 200005 ? minDiff : -1));
  return 0;
}
