#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int ans = 1e9;
int n, m, col[N], k[N], res, t[N], sum;
void print() {
  cout << endl;
  for (int i = 1; i <= m; i++) cout << t[i] << " ";
  cout << sum << endl;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) col[i] = read();
  for (int i = 1; i <= m; i++) {
    k[i] = read();
    res += k[i];
    sum += (!k[i]);
  }
  int l = 1;
  for (int r = 1; r <= n; r++) {
    ++t[col[r]];
    if (t[col[r]] == k[col[r]]) ++sum;
    if (sum == m) {
      while (l <= r && t[col[l]] > k[col[l]]) t[col[l++]]--;
      ans = min(ans, r - l + 1 - res);
    }
  }
  if (ans == 1e9) ans = -1;
  printf("%d\n", ans);
}
