#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[200005];
int v[200005];
int c[200005], lower;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  int sol = 123123123;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) {
    cin >> v[i];
    if (c[i] < v[i]) lower++;
  }
  int j = 0;
  for (int i = 1; i <= n; i++) {
    while (j < n && lower > 0) {
      j++;
      c[a[j]]++;
      if (c[a[j]] == v[a[j]]) lower--;
    }
    if (!lower) sol = min(sol, j - i + 1);
    c[a[i]]--;
    if (c[a[i]] == v[a[i]] - 1) lower++;
  }
  if (sol == 123123123)
    sol = -1;
  else
    sol = sol - accumulate(v + 1, v + m + 1, 0);
  cout << sol << '\n';
}
