#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, i, j, K[200001] = {0}, a[200001], arr[200001] = {0}, k,
                        ansstat = 0, ans = 1e9 + 7, ss = 0;
  long long ptr1 = 0, ptr2 = 0, temp[200001] = {0};
  set<long long> st;
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < m; i++) {
    cin >> K[i + 1];
    ss += K[i + 1];
  }
  for (k = 1; k <= m; k++) {
    while (ptr2 < n and temp[k] < K[k]) {
      temp[a[ptr2]]++;
      ptr2++;
    }
  }
  for (k = 1; k <= m; k++) {
    if (temp[k] < K[k]) {
      cout << -1;
      return (0);
    }
  }
  ans = ptr2 - ptr1 + 1 - ss;
  while (ptr1 < n and ptr2 <= n) {
    ans = min(ans, ptr2 - ptr1 - ss);
    i = a[ptr1];
    temp[i]--;
    while (ptr2 < n and temp[i] < K[i]) {
      temp[a[ptr2]]++;
      ptr2++;
    }
    if (ptr2 == n and temp[i] < K[i]) break;
    ans = min(ans, ptr2 - ptr1 - ss);
    ptr1++;
  }
  cout << ans;
}
