#include <bits/stdc++.h>
using namespace std;
int MIN(int a, int b) { return (a < b) ? a : b; }
int n, m;
int a[300000], k[300000], num[300000], numDef, total, totalK, ans = 1000000000;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &k[i]);
    totalK += k[i];
    if (k[i] > 0) numDef++;
  }
  if (totalK == 0) {
    printf("0\n");
    return 0;
  }
  int l = 0, r = -1;
  while (l < n && r < n - 1) {
    while (r < n - 1 && numDef > 0) {
      int tmp = a[r + 1];
      if (num[tmp] == k[tmp] - 1) numDef--;
      num[tmp]++;
      r++;
      total++;
    }
    if (numDef == 0) {
      ans = MIN(ans, total - totalK);
    } else {
      break;
    }
    while (numDef == 0) {
      int tmp = a[l];
      if (num[tmp] == k[tmp]) numDef++;
      num[tmp]--;
      l++;
      total--;
      if (numDef == 0) {
        ans = MIN(ans, total - totalK);
      }
    }
  }
  if (ans < 1000000000)
    printf("%d\n", ans);
  else
    printf("-1\n");
}
