#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e6 + 5;
int main() {
  long long int n, m, i, j;
  cin >> n >> m;
  long long int a[n], b[m + 1];
  for (i = 0; i < n; i++) cin >> a[i];
  long long int sum = 0;
  for (i = 1; i <= m; i++) cin >> b[i], sum += b[i];
  map<long long int, long long int> mp, pos;
  for (i = 0; i < n; i++) {
    if (mp[a[i]] < b[a[i]]) mp[a[i]]++, pos[a[i]] = i;
  }
  for (i = 1; i <= m; i++) {
    if (mp[i] < b[i]) {
      cout << -1;
      return 0;
    }
  }
  long long int maxi = 0;
  for (auto j : pos) maxi = max(maxi, j.second);
  map<long long int, long long int> mp1;
  for (i = 0; i <= maxi; i++) {
    mp1[a[i]]++;
  }
  long long int ans = (maxi + 1 - sum);
  j = 0;
  while (mp1[a[j]] > b[a[j]]) {
    mp1[a[j]]--;
    j++;
  }
  ans = min(ans, maxi - j + 1 - sum);
  for (i = maxi + 1; i < n; i++) {
    mp1[a[i]]++;
    while (mp1[a[j]] > b[a[j]]) {
      mp1[a[j]]--;
      j++;
    }
    ans = min(ans, i - j + 1 - sum);
  }
  cout << ans << endl;
  return 0;
}
