#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int n, m, dd[N], a[N], d[N];
bool vis[N];
inline bool check(int k) {
  for (int i = 0; i < k; i++) d[i] = dd[i];
  memset(vis, 0, sizeof vis);
  for (int j, i = k - 1; i >= 0; i--) {
    j = d[i];
    if (vis[j]) d[i] = 0;
    vis[j] = 1;
  }
  for (int i = 1; i <= m; i++)
    if (!vis[i]) return false;
  for (int cur = 0, ex = 0, cnt;;) {
    while (ex < k && d[ex] <= 0) ex++;
    if (ex >= k) break;
    cnt = a[d[ex] - 1];
    while (cur < k && cnt > 0) {
      if (d[cur] == 0) cnt--;
      if (cur > ex) return false;
      cur++;
    }
    if (cnt > 0) return false;
    ex++;
  }
  return true;
}
int main() {
  memset(vis, 0, sizeof vis);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", dd + i);
  for (int i = 0; i < m; i++) scanf("%d", a + i);
  int lo = 1, hi = n + 1, mid;
  while (hi - lo > 1) {
    mid = hi + lo >> 1;
    if (check(mid))
      hi = mid;
    else
      lo = mid;
  }
  if (hi > n) hi = -1;
  printf("%d\n", hi);
  return 0;
}
