#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), k(m);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i]--;
  }
  unordered_set<int> s;
  int cnt = 0;
  for (int i = 0; i < m; ++i) {
    cin >> k[i];
    if (k[i] > 0) s.insert(i);
    cnt += k[i];
  }
  int l = 0;
  int r = 0;
  int ans = INT_MAX;
  while (r < n && l < n) {
    if (s.size() > 0) {
      k[a[r]]--;
      if (k[a[r]] > 0)
        s.insert(a[r]);
      else
        s.erase(a[r]);
      ++r;
    } else {
      ans = min(ans, r - l - cnt);
      k[a[l]]++;
      if (k[a[l]] > 0)
        s.insert(a[l]);
      else
        s.erase(a[l]);
      ++l;
    }
  }
  while (s.size() == 0 && l < n) {
    ans = min(ans, r - l - cnt);
    k[a[l]]++;
    if (k[a[l]] > 0)
      s.insert(a[l]);
    else
      s.erase(a[l]);
    ++l;
  }
  if (ans == INT_MAX)
    cout << -1;
  else
    cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  for (int i = 1; i <= t; ++i) {
    solve();
  }
}
