#include <bits/stdc++.h>
int n, m;
int a[202202], todo[202202];
int cur[202202];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int below = 0, s = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &todo[i]);
    s += todo[i];
    if (todo[i] > 0) below++;
  }
  int ans = -1, it = 1;
  for (int i = 1; i <= n; i++) {
    int id = a[i];
    cur[id]++;
    if (cur[id] == todo[id]) below--;
    while (it < i && cur[a[it]] > todo[a[it]]) {
      cur[a[it]]--;
      it++;
    }
    if (!below) {
      if (ans == -1 || ans > i - it - s + 1) ans = i - it - s + 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
