#include <bits/stdc++.h>
using namespace std;
int n, m;
int d[100000], dd[100000];
int a[100000], aa[100000];
bool check(int x) {
  copy(a, a + m, aa);
  memset(dd, -1, sizeof(dd));
  vector<int> pos(m, -1);
  for (int i = x; i >= 0; i--) {
    if (d[i] != -1 && pos[d[i]] == -1) {
      pos[d[i]] = i;
    }
  }
  for (int i = 0; i < m; i++)
    if (pos[i] == -1) return false;
  vector<pair<int, int>> p(m);
  for (int i = 0; i < m; i++) p[i] = make_pair(pos[i], i);
  for (int i = 0; i < m; i++) dd[pos[i]] = i;
  sort(p.begin(), p.end());
  int j = 0;
  for (int i = 0; i <= x; i++) {
    if (dd[i] == -1) {
      if (j < m) {
        aa[p[j].second]--;
        if (aa[p[j].second] == 0) j++;
      }
    } else {
      if (aa[dd[i]] > 0) return false;
    }
  }
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) scanf("%d", &d[i]), d[i]--;
  for (int i = 0; i < m; i++) scanf("%d", &a[i]);
  int ok = n;
  int ng = -1;
  while (ok - ng > 1) {
    int mid = (ok + ng) / 2;
    (check(mid) ? ok : ng) = mid;
  }
  if (ok == n)
    ok = -1;
  else
    ok++;
  cout << ok << endl;
}
