#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int f[maxn], g[maxn], now[maxn], k[maxn], n, m, ans, num;
bool pan(int x) {
  int flag = 0, p = 0, sum = 0;
  memset(now, 0, sizeof(now));
  for (int i = 1; i <= x; i++) now[g[i]]++;
  for (int i = 1; i <= m; i++)
    if (now[i] < f[i])
      flag++;
    else
      sum += now[i] - f[i];
  if (!flag && sum <= x) return 1;
  for (int i = 2, j = i + x - 1; j <= n; i++, j++) {
    now[g[i - 1]]--;
    if (now[g[i - 1]] >= f[g[i - 1]])
      sum--;
    else if (now[g[i - 1]] + 1 == f[g[i - 1]])
      flag++;
    now[g[j]]++;
    if (now[g[j]] == f[g[j]])
      flag--;
    else if (now[g[j]] > f[g[j]])
      sum++;
    if (!flag && sum <= x) return 1;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &g[i]), k[g[i]]++;
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &f[i]);
    sum += f[i];
    if (f[i] > k[i]) {
      printf("-1");
      return 0;
    }
  }
  num = sum;
  int l = 0, r = 2e5;
  while (l <= r) {
    int mid = l + r >> 1;
    if (pan(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%d", ans - num);
  return 0;
}
