#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MAXN = 2e5 + 5;
const long long LINF = 1e18;
const double pi = 3.1415926535;
int n, m;
int a[MAXN], b[MAXN];
int matched[MAXN];
int main() {
  scanf("%d %d", &n, &m);
  int over = 0, numOfMatched = 0;
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 1; i <= m; i++) scanf("%d", b + i);
  for (int i = 1; i <= m; i++)
    if (b[i] == 0) numOfMatched++;
  int j = 0;
  int ans = 1e9;
  for (int i = 0; i < n; i++) {
    matched[a[i]]++;
    if (matched[a[i]] > b[a[i]])
      over++;
    else if (matched[a[i]] == b[a[i]])
      numOfMatched++;
    if (numOfMatched == m) ans = min(ans, over);
    while (j <= i && numOfMatched == m) {
      matched[a[j]]--;
      if (matched[a[j]] >= b[a[j]]) {
        --over;
        ans = min(ans, over);
      } else if (matched[a[j]] < b[a[j]])
        numOfMatched--;
      j++;
    }
  }
  printf("%d\n", ans == 1e9 ? -1 : ans);
  return 0;
}
