#include <bits/stdc++.h>
using namespace std;
using fl = long double;
using ll = long long;
using pii = pair<int, int>;
constexpr int maxn = 3e6;
int d[maxn];
int a[maxn];
int mx[maxn];
int st[maxn];
int cnt[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
    --d[i];
  }
  for (int i = 0; i < k; ++i) {
    cin >> a[i];
  }
  int l = 0, r = n + 1, m;
  for (;;) {
  label:
    if (r - l <= 1) {
      break;
    }
    m = (l + r) / 2;
    for (int i = 0; i < k; ++i) {
      mx[i] = -1;
    }
    for (int i = 0; i < m; ++i) {
      if (d[i] != -1) {
        mx[d[i]] = i;
      }
    }
    for (int i = 0; i < k; ++i) {
      if (mx[i] == -1) {
        l = m;
        goto label;
      }
    }
    for (int i = 0; i < m; ++i) {
      st[i] = -1;
    }
    for (int i = 0; i < k; ++i) {
      st[mx[i]] = i;
    }
    for (int i = 0; i < k; ++i) {
      cnt[i] = 0;
    }
    int cur = 0;
    for (int i = 0; i < m; ++i) {
      if (st[i] != -1) {
        while (cur < i) {
          if (cnt[st[i]] < a[st[i]]) {
            if (st[cur] == -1) {
              ++cnt[st[i]];
            }
            ++cur;
          } else {
            break;
          }
        }
        if (cnt[st[i]] < a[st[i]]) {
          l = m;
          goto label;
        }
      }
    }
    r = m;
  }
  cout << (r > n ? -1 : r) << '\n';
  return 0;
}
