#include <bits/stdc++.h>
using namespace std;
void JIZZ(string output = "") {
  cout << output;
  exit(0);
}
const long double PI = 3.14159265358979323846264338327950288;
const long double eps = 1e-13;
const long long mod = 1e9 + 7;
int a[200005], q[200005], c[200005], sat, more;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= m; ++i) cin >> q[i];
  for (int i = 1; i <= m; ++i)
    if (!q[i]) ++sat;
  int L = 1, R = 0, mn = n + 10;
  for (; L <= n; ++L) {
    while (R < n && sat < m) {
      ++R;
      ++c[a[R]];
      if (c[a[R]] == q[a[R]])
        ++sat;
      else if (c[a[R]] > q[a[R]])
        ++more;
    };
    ;
    if (sat == m)
      mn = min(mn, more);
    else
      break;
    --c[a[L]];
    if (c[a[L]] == q[a[L]] - 1)
      --sat;
    else
      --more;
  }
  if (mn > n) mn = -1;
  cout << mn << endl;
}
