#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
void bye() {
  cout << '\n';
  exit(0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<long long> g(n), now(m + 1);
  for (long long &v : g) cin >> v;
  for (long long i = 1; i <= m; i++) cin >> now[i];
  long long r = 0, nneed = 0;
  for (long long v : now) nneed += v;
  long long need = nneed;
  while (need && r < n) {
    if (now[g[r]] > 0) --need;
    now[g[r]]--;
    ++r;
  }
  if (need) {
    cout << -1;
    bye();
  }
  long long best = r - nneed;
  for (long long l = 0; l < n - need; l++) {
    now[g[l]]++;
    if (now[g[l]] > 0) ++need;
    while (need && r < n) {
      if (now[g[r]] > 0) --need;
      now[g[r]]--;
      ++r;
    }
    if (need) break;
    best = min(best, r - l - nneed - 1);
  }
  cout << best;
}
