#include <bits/stdc++.h>
using namespace std;
const int N = 2E5 + 7, INF = 0x3f3f3f3f;
int col[N];
int cnt[N];
int sho[N];
bool vis[N];
int main() {
  int n, m, s = 0;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &col[i]);
  int km = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &sho[i]);
    s += sho[i];
    if (sho[i]) km++;
  }
  int l = 1, r = 1, res = INF;
  for (int t = 0; r <= n; r++) {
    if (++cnt[col[r]] == sho[col[r]] && !vis[col[r]]) t++, vis[col[r]] = 1;
    if (t == km) {
      while (l <= r && cnt[col[l]] > sho[col[l]]) cnt[col[l++]]--;
      res = min(res, r - l + 1 - s);
    }
  }
  if (res == INF) res = -1;
  printf("%d\n", res);
  return 0;
}
