#include <bits/stdc++.h>
using namespace std;
int n, m, zeros = 0;
const int N = 2e5 + 5;
int a[N], b[N], f[N];
int check(int l) {
  int c = 0, match = zeros, ans = 1e8;
  memset(f, 0, sizeof f);
  for (int i = 0; i < l; i++) {
    f[a[i]]++;
    if (f[a[i]] == b[a[i]]) match++;
    if (f[a[i]] > b[a[i]]) c++;
    if (match == m) ans = min(ans, c);
  }
  for (int i = l; i < n; i++) {
    if (f[a[i - l]] == b[a[i - l]]) match--;
    if (f[a[i - l]] > b[a[i - l]]) c--;
    f[a[i - l]]--;
    f[a[i]]++;
    if (f[a[i]] == b[a[i]]) match++;
    if (f[a[i]] > b[a[i]]) c++;
    if (match == m) ans = min(ans, c);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> b[i + 1];
    if (b[i + 1] == 0) zeros++;
  }
  int ans = 1e8;
  int s = 1, e = n;
  while (s <= e) {
    int mid = (s + e) >> 1;
    int temp = check(mid);
    if (temp >= 1e8)
      s = mid + 1;
    else
      e = mid - 1, ans = min(ans, temp);
  }
  if (ans >= 1e8) ans = -1;
  cout << ans << endl;
  return 0;
}
