#include <bits/stdc++.h>
using namespace std;
void Weapons19() {
  cout << fixed << setprecision(16);
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  Weapons19();
  long long int n, m;
  cin >> n >> m;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  vector<long long int> req(m + 1);
  long long int f = 0, z = 0;
  for (long long int i = 1; i <= m; i++) {
    cin >> req[i];
    if (req[i] == 0) f++;
    z += req[i];
  }
  vector<long long int> c(m + 1);
  long long int a = 0, b = 0, ans = LLONG_MAX;
  while (1) {
    if (f == m) {
      ans = min(b - a - z, ans);
      c[v[a]]--;
      if (c[v[a]] < req[v[a]]) f--;
      a++;
    } else {
      if (b == n) break;
      c[v[b]]++;
      if (c[v[b]] == req[v[b]]) f++;
      b++;
    }
  }
  if (ans == LLONG_MAX) {
    cout << -1;
    return 0;
  }
  cout << ans;
}
