#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, d;
  cin >> n >> d;
  vector<long long int> A(n);
  for (long long int i = 0; i < n; i++) cin >> A[i];
  vector<long long int> B(d);
  long long int sum = 0;
  long long int d1 = 0;
  for (long long int i = 0; i < d; i++) {
    cin >> B[i];
    if (B[i] != 0) d1++;
    sum = sum + B[i];
  }
  vector<long long int> freq(d);
  if (sum > n) {
    cout << -1 << endl;
    return 0;
  }
  vector<long long int> count(d);
  for (long long int i = 0; i < n; i++) count[A[i] - 1]++;
  for (long long int i = 0; i < d; i++) {
    if (count[i] < B[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  long long int distinct = 0;
  long long int i;
  for (i = 0; i < n; i++) {
    freq[A[i] - 1]++;
    if (freq[A[i] - 1] == B[A[i] - 1]) distinct++;
    if (distinct == d1) break;
  }
  int j = i;
  i = 0;
  long long int ans = ((j - i + 1) - sum);
  while (j < n) {
    long long int k1 = i;
    while (1) {
      if (freq[A[k1] - 1] > B[A[k1] - 1]) {
        freq[A[k1] - 1]--;
        k1++;
      } else
        break;
    }
    i = k1;
    ans = min(ans, ((j - i + 1) - sum));
    j++;
    if (j < n) freq[A[j] - 1]++;
  }
  ans = min(ans, ((j - i + 1) - sum));
  cout << ans << endl;
}
