#include <bits/stdc++.h>
using namespace std;
int N, M, K[200001], in[200001], cant[200001];
bitset<200001> esok;
int main(int argc, char **argv) {
  esok.reset();
  cin >> N >> M;
  for (int i = 0; i < N; i++) scanf("%d", in + i);
  int need = 0;
  int cok = 0;
  for (int i = 1; i <= M; i++) {
    scanf("%d", K + i), need += K[i];
    if (K[i] == 0) cok++, esok[i] = true;
  }
  int i = 0, j = 0;
  int minerase = -1;
  for (i = 0; i < N; i++) {
    cant[in[i]]++;
    if (cant[in[i]] >= K[in[i]]) {
      if (esok[in[i]] == false) cok++;
      esok[in[i]] = true;
    }
    while (j < i && cant[in[j]] > K[in[j]]) cant[in[j]]--, j++;
    if (cok == M) {
      int erase = i - j + 1 - need;
      if (minerase == -1 || minerase > erase) minerase = erase;
    }
  }
  cout << minerase << endl;
  return 0;
}
