#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int n, m;
  cin >> n >> m;
  std::vector<int> a(n + 1, 0);
  std::vector<int> k(m + 1, 0);
  std::vector<int> cur(m + 1, 0);
  std::vector<int> d(m + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cur[0] = 0;
  int all = 0;
  for (int i = 1; i < m + 1; i++) {
    cin >> k[i];
    all += k[i];
  }
  int r = 0;
  int dept = 0;
  int ans = n;
  for (int l = 0; l < n; l++) {
    if (l) {
      if (cur[a[l - 1]] > k[a[l - 1]])
        dept--;
      else
        all++;
      cur[a[l - 1]]--;
    }
    while (all && r < n) {
      if (cur[a[r]] < k[a[r]]) {
        all--;
      } else {
        dept++;
      }
      cur[a[r]]++;
      r++;
    }
    if (all)
      continue;
    else {
      ans = min(ans, dept);
    }
  }
  if (ans == n)
    cout << -1;
  else
    cout << ans;
}
