#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a[200009], k[200009], vis[200009], has[200009];
long long need;
long long le;
int main() {
  while (~scanf("%lld%lld", &n, &m)) {
    for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
    le = m;
    need = 0;
    for (long long i = 1; i <= m; i++) {
      scanf("%lld", &k[i]);
      need += k[i];
      vis[i] = has[i] = 0;
      if (k[i] == 0) {
        vis[i] = 1;
        le--;
      }
    }
    long long ans = 2000000000000000LL;
    long long l = 1, r = 1;
    while (r <= n) {
      has[a[r]]++;
      if (!vis[a[r]] && has[a[r]] >= k[a[r]]) {
        le--;
        vis[a[r]] = 1;
      }
      if (le == 0) {
        while (has[a[l]] > k[a[l]]) {
          has[a[l]]--;
          l++;
        }
        ans = min(ans, (r - l + 1) - need);
        has[a[l]]--;
        vis[a[l]] = 0;
        l++;
        le++;
      }
      r++;
    }
    if (ans == 2000000000000000LL)
      printf("-1\n");
    else
      printf("%lld\n", ans);
  }
}
