#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int INF = 1e9;
const int MAX = 505, N = 210;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<int> v(n), col(m, 0);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    v[i]--;
  }
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    cin >> col[i];
    cnt += col[i];
  }
  vector<int> tc(col.begin(), col.end());
  for (int i = 0; i < n; i++) {
    tc[v[i]]--;
  }
  int mx = *max_element(tc.begin(), tc.end());
  if (mx > 0) {
    cout << -1 << "\n";
    return 0;
  }
  int ans = n;
  int tmp = 0;
  int l = 0, r = 0;
  while (1) {
    if (cnt > 0 && r < n) {
      if (col[v[r]] > 0) {
        cnt--;
      } else
        tmp++;
      col[v[r++]]--;
    } else if (l < n) {
      if (col[v[l]] < 0)
        tmp--;
      else
        cnt++;
      col[v[l++]]++;
    }
    if (cnt == 0) ans = min(ans, tmp);
    if (l == n && r == n) break;
  }
  cout << ans << "\n";
  return 0;
}
void buildPi(string& p, vector<int>& pi) {
  pi = vector<int>(p.length());
  int k = -2;
  for (int i = 0; i < p.length(); i++) {
    while (k >= -1 && p[k + 1] != p[i]) k = (k == -1) ? -2 : pi[k];
    pi[i] = ++k;
  }
}
vector<int> KMP(string& t, string& p) {
  vector<int> pi, ret;
  buildPi(p, pi);
  int k = -1;
  for (int i = 0; i < t.length(); i++) {
    while (k >= -1 && p[k + 1] != t[i]) k = (k == -1) ? -2 : pi[k];
    k++;
    if (k == p.length() - 1) {
      ret.push_back(i - k);
      k = (k == -1) ? -2 : pi[k];
    }
  }
  return ret;
}
