#include <bits/stdc++.h>
using namespace std;
const long long N = 5 * (1e5);
const long long md = 1000000007;
const long long mx = (1e18);
const long double pi = 3.1415926535897932384626433832795;
long long kol, c[N], r, d[N], a[N], b[N], n, m, k, w, j, i, l, dd[N], q, e, res,
    sum, cc;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first < b.first || a.first == b.first && a.second > b.second;
}
long long bp(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2 == 1)
    return (bp(a, b - 1) * a) % md;
  else {
    long long c = (bp(a, b / 2)) % md;
    return (c * c) % md;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= m; i++) cin >> c[i];
  l = 1;
  r = n;
  while (l < r) {
    long long cc = (l + r) / 2;
    w = 0;
    for (i = 1; i <= m; i++) b[i] = 0;
    for (i = 1; i <= n; i++) {
      dd[i] = 0;
      d[i] = 0;
    }
    for (i = cc; i >= 1; i--)
      if (b[a[i]] == 0) b[a[i]] = i;
    for (i = 1; i <= m; i++) d[b[i]] += c[i];
    kol = 0;
    for (i = 1; i <= cc; i++) {
      if (d[i] != 0) {
        kol++;
        w -= d[i];
      } else
        w++;
      if (w < 0) break;
    }
    if (w < 0 || kol < m)
      l = cc + 1;
    else
      r = cc;
  }
  cc = l;
  w = 0;
  kol = 0;
  for (i = 1; i <= m; i++) b[i] = 0;
  for (i = 1; i <= cc; i++) d[i] = 0;
  for (i = cc; i >= 1; i--)
    if (b[a[i]] == 0) b[a[i]] = i;
  for (i = 1; i <= m; i++) d[b[i]] += c[i];
  for (i = 1; i <= cc; i++) {
    if (d[i] != 0) {
      kol++;
      w -= d[i];
    } else
      w++;
    if (w < 0) break;
  }
  if (w < 0 || kol < m)
    cout << -1;
  else
    cout << l;
}
