#include <bits/stdc++.h>
using namespace std;
int a[300005], K[300005], cc[300005];
int n, m, total;
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]), total += K[i];
  int ok = 0, ans = 1e7;
  for (int i = 1; i <= n; i++) cc[a[i]]++;
  for (int i = 1; i <= m; i++)
    if (cc[i] >= K[i]) ok++;
  if (ok != m) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= m; i++) cc[i] = 0;
  int j = n + 1;
  ok = 0;
  for (int i = 1; i <= m; i++)
    if (!K[i]) ok++;
  while (j > 1 && ok < m) {
    j--;
    cc[a[j]]++;
    if (cc[a[j]] == K[a[j]]) ok++;
  }
  ans = (n - j + 1) - total;
  for (int i = n; i >= 1; i--) {
    if (cc[a[i]] == K[a[i]]) ok--;
    cc[a[i]]--;
    while (j > 1 && ok < m) {
      j--;
      cc[a[j]]++;
      if (cc[a[j]] == K[a[j]]) ok++;
    }
    if (ok == m) ans = min(ans, ((i - 1) - j + 1) - total);
  }
  cout << ans << endl;
}
