#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N], b[N];
int sum[N], tmp[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int cnt = 0;
  int tp = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    if (b[i]) cnt++;
    tp += b[i];
  }
  int i = 1, j = 1;
  while (j <= n) {
    sum[a[j]]++;
    if (sum[a[j]] == b[a[j]]) cnt--;
    if (!cnt) break;
    j++;
  }
  if (j > n) {
    printf("-1\n");
    return 0;
  }
  int ans = j - i + 1 - tp;
  for (i = 1; i <= n; i++) {
    sum[a[i]]--;
    if (sum[a[i]] < b[a[i]]) cnt++;
    bool ff = true;
    while (cnt) {
      if (j == n) {
        ff = false;
        break;
      }
      j++;
      sum[a[j]]++;
      if (sum[a[j]] == b[a[j]]) cnt--;
    }
    if (!ff) break;
    ans = min(ans, j - i - tp);
  }
  printf("%d\n", ans);
  return 0;
}
