#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 1;
int main() {
  int n, m, a[MAX_N] = {}, i, k[MAX_N] = {}, c[MAX_N] = {}, sumk = 0, l, r,
            cnt = 0, ans = 1e9, v;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= m; i++) {
    scanf("%d", &k[i]);
    sumk += k[i];
    cnt += !k[i];
  }
  l = r = 0;
  while (l < n) {
    while (cnt < m && r < n) {
      v = a[r];
      c[v]++;
      if (c[v] == k[v]) cnt++;
      r++;
    }
    if (cnt < m) break;
    ans = min(ans, r - l - sumk);
    v = a[l];
    if (c[v] == k[v]) cnt--;
    c[v]--;
    l++;
  }
  if (ans == 1e9)
    puts("-1");
  else
    printf("%d", ans);
  return 0;
};
