#include <bits/stdc++.h>
using namespace std;
int N, M, A[200005], B[200005];
int Now[200005];
int Min;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 0; i <= N - 1; i++) cin >> A[i];
  for (int i = 1; i <= M; i++) cin >> B[i];
  int e = 0;
  int d = 0;
  int fi = 0;
  for (int i = 1; i <= M; i++)
    if (B[i] == 0) fi++;
  while (e < N) {
    Now[A[e]]++;
    if (Now[A[e]] == B[A[e]])
      fi++;
    else if (Now[A[e]] > B[A[e]])
      d++;
    if (fi == M) break;
    e++;
  }
  if (e == N) {
    cout << -1 << '\n';
    return 0;
  }
  Min = d;
  for (int i = 1; i <= N - 1; i++) {
    Now[A[i - 1]]--;
    if (Now[A[i - 1]] >= B[A[i - 1]]) {
      d--;
      Min = min(Min, d);
    } else {
      e++;
      while (e < N) {
        Now[A[e]]++;
        if (A[e] == A[i - 1])
          break;
        else
          d++;
        e++;
      }
      if (e == N) break;
    }
  }
  cout << Min << '\n';
  return 0;
}
