#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int n, m, sum = 0;
int a[maxn], cnt[maxn], k[maxn];
bool valid(int x) {
  for (int i = 1; i <= m; i++) cnt[i] = 0;
  for (int i = 1; i <= x; i++) cnt[a[i]]++;
  for (int i = x + 1; i <= n + 1; i++) {
    bool flag = true;
    for (int ii = 1; ii <= m; ii++)
      if (cnt[ii] < k[ii]) {
        flag = false;
        break;
      }
    if (flag)
      return true;
    else {
      cnt[a[i - x]]--;
      cnt[a[i]]++;
    }
  }
  return false;
}
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", &k[i]);
    sum += k[i];
  }
  int l = sum, r = n, mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (valid(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  if (l == n + 1)
    puts("-1");
  else
    printf("%d\n", l - sum);
  return 0;
}
