#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, ans, mx = 0, sum = 0;
int a[N], b[N], cnt[N], nxt[N], head[N], pos[N];
int main() {
  int i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= m; i++) scanf("%d", &b[i]), sum += b[i];
  for (i = 1; i <= n; i++) cnt[a[i]]++;
  for (i = 1; i <= m; i++)
    if (cnt[i] < b[i]) {
      printf("-1\n");
      return 0;
    }
  for (i = 1; i <= m; i++) head[i] = n + 1;
  for (i = n; i >= 1; i--) {
    nxt[i] = head[a[i]];
    head[a[i]] = i;
  }
  for (i = 1; i <= m; i++) {
    if (!b[i]) continue;
    pos[i] = head[i];
    for (j = 1; j < b[i]; j++) pos[i] = nxt[pos[i]];
    mx = max(mx, pos[i]);
  }
  ans = n - sum;
  ans = min(ans, mx - sum);
  for (i = 1; i < n; i++) {
    pos[a[i]] = nxt[pos[a[i]]];
    mx = max(mx, pos[a[i]]);
    if (mx > n) break;
    ans = min(ans, mx - i - sum);
  }
  printf("%d\n", ans);
  return 0;
}
