#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, t, tot, sum, ans, a[N], b[N], c[N];
int main() {
  scanf("%d%d", &n, &m), ans = n + 1;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  t = 0, tot = m, sum = 0;
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &b[i]), c[i] = -b[i];
    if (c[i] == 0) --tot;
  }
  for (int i = 1; i <= n; ++i) {
    while (t < n && tot > 0) {
      ++t, ++c[a[t]];
      if (c[a[t]] == 0) --tot;
      if (c[a[t]] > 0) ++sum;
      if (tot == 0) break;
    }
    if (tot != 0) break;
    ans = min(ans, sum);
    --c[a[i]];
    if (c[a[i]] == -1) ++tot;
    if (c[a[i]] >= 0) --sum;
    if (tot == 0) ans = min(ans, sum);
  }
  if (ans > n) ans = -1;
  printf("%d\n", ans);
  return 0;
}
