#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
const int mod = 998244353;
const ll inf = ll(1e18);
const double PI = acos(-1), eps = 1e-9;
const int mxa = 2e3;
ll ncr[mxa + 5][mxa + 5];
void init() {
  for (int i = 0; i <= mxa; ++i) {
    ncr[i][i] = ncr[i][0] = 1;
    for (int j = 1; j < i; ++j) {
      ncr[i][j] = (ncr[i - 1][j - 1] + ncr[i - 1][j]) % mod;
    }
  }
}
const int mxn = 2e5, mxk = 2e3;
int n, m, d[mxn + 5], a[mxn + 5];
bool ok(int k) {
  map<int, bool> found;
  vi order, cnt(m + 1);
  for (int i = k; i >= 1; --i) {
    if (d[i] && !found.count(d[i])) {
      found[d[i]] = 1;
      order.push_back(d[i]);
    }
  }
  reverse(order.begin(), order.end());
  if ((int)(order).size() < m) return false;
  int i = 0;
  for (int j = 1; j <= k; ++j) {
    if (d[j] && cnt[d[j]] == a[d[j]] && found[d[j]]) {
      found[d[j]] = 0;
    } else if (i < m) {
      ++cnt[order[i]];
      if (cnt[order[i]] == a[order[i]]) ++i;
    }
  }
  for (const auto &p : found) {
    if (p.second == 1) return false;
  }
  return true;
}
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> d[i];
  for (int i = 1; i <= m; ++i) cin >> a[i];
  int lo = 1, hi = n + 1;
  while (lo < hi) {
    int mid = lo + (hi - lo) / 2;
    ok(mid) ? hi = mid : lo = mid + 1;
  }
  cout << (lo == n + 1 ? -1 : lo) << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  t = 1;
  while (t-- > 0) solve();
}
