#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, m, a[N], b[N], p[N];
int main() {
  scanf("%d%d", &n, &m);
  int sum = 0, R = 0, ok = 0, ans = 1 << 29;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    sum += b[i];
  }
  for (int i = 1; i <= m; i++)
    if (!b[i]) ok++;
  for (int i = 1; i <= n; i++) {
    while (ok < m && R < n) {
      R++;
      p[a[R]]++;
      if (p[a[R]] == b[a[R]]) ok++;
    }
    if (ok < m && R == n) break;
    if (ok == m) ans = min(ans, R - i + 1 - sum);
    if (p[a[i]] == b[a[i]]) ok--;
    p[a[i]]--;
  }
  if (ans == 1 << 29)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
