#include <bits/stdc++.h>
using namespace std;
long long b[500005], a[500005], m, n, r, u = 0;
long long vis[500005], co[500005];
long long check(long long x) {
  long long i, j, k, l;
  vis[0] = 0;
  for (i = 0; i < 500005; i++) vis[i] = 0, co[i] = 0;
  l = 0;
  for (i = x; i > 0; i--) {
    j = b[i];
    if (j > 0 && co[j] == 0) vis[i] = j, co[j] = 1, l++;
  }
  if (l != m) return 0;
  k = 0;
  for (i = 1; i <= x; i++) {
    if (vis[i] != 0) {
      j = vis[i];
      if (k < a[j]) return 0;
      k -= a[j];
    } else
      k++;
  }
  return 1;
}
int main() {
  long long i, j, k, l = 0, x, y, q = 0, z;
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> b[i];
  for (i = 1; i <= m; i++) cin >> a[i];
  x = 1;
  y = n;
  while (x < y) {
    long long mid = x + y;
    mid = mid / 2;
    z = check(mid);
    if (z)
      y = mid;
    else
      x = mid + 1;
  }
  long long t = min(x, y);
  if (check(t))
    r = t;
  else if (check(t + 1))
    r = t + 1;
  else
    r = -1;
  cout << r << endl;
  return 0;
}
