#include <bits/stdc++.h>
using namespace std;
int n, m;
bool check(int len, vector<int> &jedi, vector<int> k) {
  int pass = 0;
  for (int c = 1; c < (int)k.size(); c++) {
    if (k[c] == 0) {
      pass += 1;
    }
  }
  for (int i = 0; i < len; i++) {
    int c = jedi[i];
    k[c] -= 1;
    if (k[c] == 0) {
      pass += 1;
    }
  }
  if (pass >= m) return true;
  for (int i = 1; i + len - 1 < n; i++) {
    int c = jedi[i - 1];
    k[c] += 1;
    if (k[c] == 1) {
      pass -= 1;
    }
    c = jedi[i + len - 1];
    k[c] -= 1;
    if (k[c] == 0) {
      pass += 1;
    }
    if (pass >= m) return true;
  }
  return false;
}
int main() {
  scanf("%d %d", &n, &m);
  vector<int> jedi(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &jedi[i]);
  }
  vector<int> k(m + 1);
  int sum_k = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d", &k[i + 1]);
    sum_k += k[i + 1];
  }
  int l = sum_k;
  int r = n;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (check(mid, jedi, k)) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  if (check(r, jedi, k))
    printf("%d\n", r - sum_k);
  else
    printf("-1\n");
  return 0;
}
