#include <bits/stdc++.h>
using namespace std;
bool comparator(pair<long long, long long> a, pair<long long, long long> b) {
  return a.second < b.second;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  map<long long, long long> curr;
  vector<long long> inp(n);
  vector<long long> kVal(m);
  for (long long i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    x--;
    inp[i] = x;
  }
  for (long long j = 0; j < m; ++j) cin >> kVal[j];
  long long s, e;
  s = e = 0;
  long long negFlag = false;
  for (long long i = 0; i < m; i++) {
    while (curr[i] < kVal[i] && e < n) {
      curr[inp[e]]++;
      e++;
    }
    if (e == n && curr[i] < kVal[i]) {
      negFlag = true;
      break;
    }
  }
  if (negFlag == true) {
    cout << -1;
    return 0;
  }
  while (1) {
    if (curr[inp[s]] > kVal[inp[s]]) {
      curr[inp[s]]--;
      s++;
    } else
      break;
  }
  long long answer;
  long long init = 0;
  for (long long i = 0; i < m; i++) {
    init += (curr[i] - kVal[i]);
  }
  answer = init;
  while (e < n) {
    if (curr[inp[s]] > kVal[inp[s]]) {
      curr[inp[s]]--;
      s++;
      init--;
      answer = min(answer, init);
    } else {
      curr[inp[e]]++;
      e++;
      init++;
      answer = min(answer, init);
    }
  }
  cout << answer << endl;
}
