#include <bits/stdc++.h>
using namespace std;
int N, M, A[200000], K[200000], cou[200000], tot;
bool f(int x) {
  memset((cou), 0, sizeof(cou));
  int satisfy = 0, overflow = 0;
  for (int i = 0; i < M; i++) {
    if (K[i] == 0) satisfy++;
  }
  for (int i = 0; i < tot + x; i++) {
    if (cou[A[i]] >= K[A[i]]) overflow++;
    cou[A[i]]++;
    if (cou[A[i]] == K[A[i]]) satisfy++;
  }
  int l = 0;
  int r = tot + x - 1;
  while (r < N) {
    if (satisfy == M && overflow <= x) return 1;
    if (cou[A[l]] > K[A[l]]) overflow--;
    if (cou[A[l]] == K[A[l]]) satisfy--;
    cou[A[l]]--;
    l++;
    r++;
    if (r < N) {
      if (cou[A[r]] >= K[A[r]]) overflow++;
      cou[A[r]]++;
      if (cou[A[r]] == K[A[r]]) satisfy++;
    }
  }
  return 0;
}
int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    A[i]--;
  }
  tot = 0;
  for (int i = 0; i < M; i++) {
    scanf("%d", &K[i]);
    tot += K[i];
  }
  int l = 0;
  int r = N - tot + 1;
  while (l < r) {
    int m = (l + r) / 2;
    if (!f(m))
      l = m + 1;
    else
      r = m;
  }
  if (l == N - tot + 1) l = -1;
  printf("%d\n", l);
  return 0;
}
