#include <bits/stdc++.h>
using namespace std;
bool isprime[2000005];
void setprime() {
  for (long long i = 0; i < 2000005; i++) isprime[i] = true;
  isprime[0] = false;
  isprime[1] = false;
  for (long long i = 2; i < 2000005; i++) {
    for (long long j = 2; i * j < 2000005; j++) isprime[i * j] = false;
  }
}
long long choose(long long n, long long k) {
  if (k == 0) return 1;
  return (n * choose(n - 1, k - 1)) / k;
}
long long gcd(long long a, long long b) {
  if (!a) return b;
  return gcd(b % a, a);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long a[n], b[m + 1], c[200001];
  for (long long i = 0; i < 200001; i++) {
    c[i] = 0;
  }
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long sum = 0;
  for (long long i = 1; i < m + 1; i++) {
    cin >> b[i];
    sum += b[i];
  }
  long long ans = n;
  long long l = 0;
  long long r = n;
  long long count = 0;
  for (long long i = 0; i < n; i++) {
    if (c[a[i]] < b[a[i]]) count++;
    c[a[i]]++;
    if (count == sum) {
      r = i;
      break;
    }
  }
  if (r == n)
    cout << -1;
  else {
    while (r < n) {
      while (l < n && c[a[l]] > b[a[l]]) {
        c[a[l]]--;
        l++;
      }
      if (r - l + 1 < ans) ans = r - l + 1;
      r++;
      if (r < n) c[a[r]]++;
    }
    while (l < n && c[a[l]] > b[a[l]]) {
      c[a[l]]--;
      l++;
    }
    if (r - l + 1 < ans) ans = r - l + 1;
    cout << ans - sum;
  }
  return 0;
}
