#include <bits/stdc++.h>
const double Pi = 3.14159265;
const double e = 2.71828182;
const int N = 3e5 + 5;
const unsigned long long base = 163;
const int INF = 0x3f3f3f3f;
using namespace std;
int a[N];
int b[N];
int main() {
  int n, m;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int sum = 0;
  int pp = 0;
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    if (b[i] == 0) sum++;
    pp += b[i];
  }
  int c[N];
  int l = 1, r = 1;
  int MIN = INF;
  int op = 0;
  for (;;) {
    while (r <= n && sum < m) {
      c[a[r]]++;
      if (c[a[r]] == b[a[r]]) sum++;
      r++;
    }
    if (sum < m) break;
    MIN = min(MIN, r - l - pp);
    if (c[a[l]] == b[a[l]]) sum--;
    c[a[l]]--;
    l++;
  }
  if (MIN != INF)
    cout << MIN << endl;
  else
    cout << -1 << endl;
  return 0;
}
