#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
int n, m, num, cnt, ans = INF;
int a[MAXN], b[MAXN], c[MAXN];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    if (b[i] == 0) cnt++;
    num += b[i];
  }
  int l = 1, r = 1;
  for (; r <= n; r++) {
    c[a[r]]++;
    if (c[a[r]] == b[a[r]]) {
      cnt++;
      if (cnt == m) break;
    }
  }
  if (r == n + 1) return 0 * puts("-1");
  while (c[a[l]] > b[a[l]]) {
    c[a[l]]--;
    l++;
  }
  ans = min(ans, r - l + 1 - num);
  for (r++; r <= n; r++) {
    c[a[r]]++;
    if (a[r] == a[l]) {
      while (c[a[l]] > b[a[l]]) {
        c[a[l]]--;
        l++;
      }
      ans = min(ans, r - l + 1 - num);
    }
  }
  printf("%d\n", max(ans, 0));
  return 0;
}
