#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 105;
int vis[N], need[N], a[N];
void solve() {
  int n, m, ans = 1e9;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int need_sum = 0, need_cont = 0, up = 0;
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &need[i]);
    up += need[i] > 0;
    need_sum += need[i];
  }
  int l = 1, r = 0;
  while (l <= n) {
    while (r <= n && need_cont < up) {
      ++r;
      vis[a[r]]++;
      if (vis[a[r]] == need[a[r]]) need_cont++;
    }
    if (r > n) break;
    ans = min(ans, r - l + 1 - need_sum);
    vis[a[l]]--;
    if (vis[a[l]] < need[a[l]]) --need_cont;
    ++l;
  }
  if (ans == 1e9) ans = -1;
  printf("%d\n", ans);
}
int main() {
  int _ = 1;
  for (int i = 1; i <= _; ++i) solve();
}
