#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 2;
int n, m;
int aa[N], bb[N];
int fr[N];
int main() {
  scanf("%d%d", &n, &m);
  int lar = 0, mn = n, eq = 0, l = 1;
  for (int i = 1; i <= n; i++) scanf("%d", &aa[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &bb[i]), eq += bb[i] == 0;
  for (int i = 1; i <= n; i++) {
    fr[aa[i]]++;
    if (fr[aa[i]] == bb[aa[i]])
      eq++;
    else if (fr[aa[i]] > bb[aa[i]])
      lar++;
    while (eq == m) {
      mn = min(mn, lar);
      fr[aa[l]]--;
      if (fr[aa[l]] < bb[aa[l]])
        eq--;
      else
        lar--;
      l++;
    }
  }
  if (mn == n) mn = -1;
  printf("%d\n", mn);
  return 0;
}
