#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
queue<int> a[N];
int ad[N], c[N], cc[N], c3[N];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", ad + i);
    a[ad[i]].push(i);
  }
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &c[i]);
    cc[i] = c[i];
    sum += c[i];
  }
  int s = sum, j = 1;
  for (; j <= n && s; j++) {
    if (cc[ad[j]]) {
      s--;
      cc[ad[j]]--;
    }
    ++c3[ad[j]];
    a[ad[j]].pop();
    if (!s) break;
  }
  if (s) return cout << "-1", 0;
  int mn = j;
  for (int i = 2; i <= n - sum + 1; i++) {
    c3[ad[i - 1]]--;
    while (c3[ad[i - 1]] < c[ad[i - 1]] && a[ad[i - 1]].size()) {
      j = max(j, a[ad[i - 1]].front());
      a[ad[i - 1]].pop();
      ++c3[ad[i - 1]];
    }
    if (c3[ad[i - 1]] < c[ad[i - 1]]) break;
    mn = min(mn, j - i + 1);
  }
  printf("%d", max(0, mn - sum));
  return 0;
}
