#include <bits/stdc++.h>
using namespace std;
const long long int mod = 998244353ll;
const long long int P = 1000000009ll;
const long long int N = 200005ll;
bool cmp(pair<pair<long long int, long long int>, bool> x,
         pair<pair<long long int, long long int>, bool> y) {
  return x.first.first > y.first.first;
}
long long int a[N], b[N], c[N];
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int ans = 1e18;
  for (long long int i = (1); i <= (n); ++i) cin >> a[i];
  long long int sum = 0;
  long long int m1 = m;
  for (long long int i = (1); i <= (m1); ++i) {
    cin >> b[i];
    sum += b[i];
    if (b[i] == 0) m--;
  }
  long long int prev = 0;
  for (long long int i = (1); i <= (n); ++i) {
    ++c[a[i]];
    if (c[a[i]] == b[a[i]]) m--;
    while (c[a[prev + 1]] > b[a[prev + 1]]) {
      prev++;
      --c[a[prev]];
    }
    if (m == 0) {
      ans = min(ans, i - prev - sum);
      prev++;
      --c[a[prev]];
      ++m;
    }
  }
  if (ans == 1e18)
    cout << -1;
  else
    cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
