#include <bits/stdc++.h>
using namespace std;
int dp[200004];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int arr[n + 1];
  for (int i = 1; i <= n; i++) scanf("%d", arr + i);
  int color[m + 1];
  int sumcolor = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", color + i);
    sumcolor += color[i];
  }
  for (int i = 1; i <= m; i++) {
    dp[i] = color[i];
  }
  int sum = 0;
  int j = 1;
  int ans = n + 1;
  int count = 0;
  for (int i = 1; i <= m; i++)
    if (color[i] != 0) count++;
  if (count == 0) {
    printf("0");
    exit(0);
  }
  for (int i = 1; i <= n; i++) {
    sum++;
    if (count > 0) {
      dp[arr[i]]--;
      if (dp[arr[i]] == 0) {
        count--;
      }
    }
    while (count <= 0) {
      ans = min(sum - sumcolor, ans);
      sum--;
      dp[arr[j]]++;
      if (dp[arr[j]] == 1) {
        count++;
      }
      j++;
    }
  }
  printf("%d", ans == (n + 1) ? -1 : ans);
}
