#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, INF = 1e9;
deque<int> q[N];
int a[N], b[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  int sum = 0, trash = 0;
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    sum += b[i];
    if (b[i] == 0) trash++;
  }
  m -= trash;
  int ans = INF;
  set<int> st;
  for (int i = 0; i < n; i++) {
    int x = a[i];
    if (b[x] > 0) {
      if (q[x].size() == b[x]) st.erase(q[x].front());
      q[x].push_back(i);
      if (q[x].size() > b[x]) q[x].pop_front();
      if (q[x].size() == b[x]) st.insert(q[x].front());
    }
    if (st.size() == m) {
      ans = min(ans, i - *st.begin() + 1 - sum);
    }
  }
  cout << (ans == INF ? -1 : ans);
  return 0;
}
