#include <bits/stdc++.h>
using namespace std;
int a[200000];
int b[200001];
int br[200001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) cin >> b[i];
  int minimum = 0;
  for (int i = 1; i <= m; i++) minimum += b[i];
  int ok = 0;
  for (int i = 1; i <= m; i++) ok += !b[i];
  int left = 0;
  int ans = n + 1;
  for (int right = 0; right < n; right++) {
    br[a[right]]++;
    if (br[a[right]] == b[a[right]]) ok++;
    while (ok == m) {
      ans = min(ans, right - left + 1);
      if (br[a[left]] == b[a[left]]) ok--;
      br[a[left]]--;
      left++;
    }
  }
  if (ans == n + 1)
    cout << -1 << endl;
  else
    cout << ans - minimum << endl;
  return 0;
}
