#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n), k(m + 1), c(m + 1);
  long long sum = 0;
  long long ans = LLONG_MAX;
  int cnt = 0;
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 1; i <= m; i++) {
    cin >> k[i];
    if (k[i] == 0) cnt++;
    sum += k[i];
  }
  int l = 0;
  for (int i = 0; i < n; i++) {
    c[v[i]]++;
    if (c[v[i]] == k[v[i]]) cnt++;
    while (cnt == m) {
      ans = min(ans, i - l + 1 - sum);
      if (c[v[l]] == k[v[l]]) cnt--;
      c[v[l]]--;
      l++;
      if (cnt < m) break;
    }
  }
  cout << (ans == LLONG_MAX ? -1 : ans);
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
