#include <bits/stdc++.h>
const int MAXINT = 2147483640;
const long long MAXLL = 9223372036854775800LL;
const long long MAXN = 1000000;
const double pi = 3.1415926535897932384626433832795;
using namespace std;
long long l, r, n, m, i, s = 0, a[MAXN], k[MAXN], f[MAXN], d[MAXN], p[MAXN],
                         b[MAXN];
int check(long long c) {
  long long kol = 0, q = 0;
  for (i = 1; i <= m; i++) f[i] = 0;
  for (i = 1; i <= c; i++) b[i] = 0;
  for (i = c; i > 0; i--)
    if (a[i] != 0 && f[a[i]] == 0) {
      f[a[i]] = 1;
      p[++kol] = a[i];
      b[i] = 1;
    }
  if (kol < m) return 0;
  long long pos = kol;
  for (i = 1; i <= m; i++) f[i] = 0;
  for (i = 1; i <= c; i++) {
    ++q;
    q -= b[i];
    if (a[i] == p[pos])
      if (q >= k[a[i]]) --pos, q -= k[a[i]];
    if (pos == 0) return 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  srand(time(0));
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= m; i++) cin >> k[i];
  if (check(n) == 0) {
    cout << -1 << endl;
    return 0;
  }
  l = 0;
  r = n;
  while (l < r) {
    long long c = (l + r) / 2;
    if (check(c))
      r = c;
    else
      l = c + 1;
  }
  cout << l << endl;
  return 0;
}
