#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int num[N];
int a[N], b[N];
int main() {
  int n, m, tot = 0;
  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", &b[i]), tot += b[i];
  int le = 1, ri = 0;
  int cnt = 0;
  for (int i = 1; i <= m; i++) cnt += (num[i] == b[i]);
  int ans = n + 1;
  while (ri < n) {
    if (cnt == m) ans = min(ans, ri - le + 1 - tot);
    ri++;
    num[a[ri]]++;
    if (num[a[ri]] == b[a[ri]]) cnt++;
    while (num[a[le]] > b[a[le]]) {
      num[a[le]]--;
      le++;
    }
  }
  if (cnt == m) ans = min(ans, ri - le + 1 - tot);
  if (ans == n + 1) ans = -1;
  printf("%d\n", ans);
}
