#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const long long mod = 1e9 + 7;
int n, m, m_;
int a[maxn], cnt[maxn];
int t[maxn], summ;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  summ = 0;
  m_ = 0;
  memset(t, 0, sizeof t);
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &cnt[i]);
    summ += (cnt[i]);
    if (cnt[i]) m_++;
  }
  int sum = 0, l = 1, r = 0;
  int ans = n + 1;
  while (r <= n) {
    r++;
    t[a[r]]++;
    if (t[a[r]] == cnt[a[r]]) sum++;
    if (sum == m_) {
      while (t[a[l]] > cnt[a[l]]) {
        t[a[l]]--;
        l++;
      }
      ans = min(ans, (r - l + 1));
    }
  }
  if (ans == n + 1)
    puts("-1");
  else {
    printf("%d\n", ans - summ);
  }
  return 0;
}
