#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long read1() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 2e5 + 10;
inline int min(int a, int b) {
  if (a < b) return a;
  return b;
}
int n, m, ans, mx, sum, a[N], b[N], cnt[N], nxt[N], head[N], pos[N];
bool tag;
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) a[i] = read(), cnt[a[i]]++;
  for (int i = 1; i <= m; i++) b[i] = read(), sum += b[i];
  for (int i = 1; i <= m; i++)
    if (cnt[i] < b[i]) {
      printf("-1\n");
      return 0;
    }
  for (int i = 1; i <= m; i++) head[i] = n + 1;
  for (int i = n; i >= 1; i--) nxt[i] = head[a[i]], head[a[i]] = i;
  for (int i = 1; i <= m; i++) {
    if (!b[i]) continue;
    pos[i] = head[i];
    for (int j = 1; j <= b[i] - 1; j++) pos[i] = nxt[pos[i]];
    mx = max(mx, pos[i]);
  }
  ans = n - sum;
  ans = min(ans, mx - sum);
  for (int i = 1; i <= n - 1; 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", ans);
  return 0;
}
