#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 7;
long long n, m, mrk = -1, a[maxn], b[maxn];
bool check(long long r) {
  if (m > r) return false;
  long long cnt = 0, cnt1 = 0;
  bool mark[maxn];
  stack<long long> s;
  for (long long i = 0; i < maxn; i++) mark[i] = false;
  for (long long i = r; i >= 1; i--) {
    if (mark[a[i]] == false && a[i] != 0) {
      mark[a[i]] = true;
      cnt++;
      s.push(i);
    }
  }
  if (cnt == m) {
    while (s.size()) {
      long long y = s.top();
      long long x = a[y];
      s.pop();
      if (y - 1 - b[x] - cnt1 >= 0)
        cnt1 += b[x] + 1;
      else
        return false;
    }
    return true;
  }
  return false;
}
void bs(long long l, long long r) {
  if (l == r) {
    if (check(l))
      cout << l;
    else
      cout << mrk;
    return;
  }
  long long mid = (l + r) / 2;
  if (check(mid)) {
    mrk = mid;
    bs(l, mid);
  } else
    bs(mid + 1, r);
}
int32_t main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= m; i++) cin >> b[i];
  bs(1, n);
}
