#include <bits/stdc++.h>
using namespace std;
long long x, ar[200002 + 2];
long long br[200002 + 2];
vector<int> v[200002 + 2];
int n, m;
set<long long> St;
vector<pair<int, int> > vp;
bool Ok(long long md) {
  vp.clear();
  for (int i = 1; i <= m; i++) {
    int ub = upper_bound(v[i].begin(), v[i].end(), md) - v[i].begin();
    ub--;
    vp.push_back(make_pair(v[i][ub], i));
  }
  sort(vp.begin(), vp.end());
  long long tot = 0LL;
  for (int i = 0; i < m; i++) {
    int id = vp[i].first;
    int vl = vp[i].second;
    long long faka = (id - tot - 1);
    if (br[vl] > faka) return false;
    tot += (br[vl] + 1);
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  long long lst = 0, f = 1;
  int i, j;
  long long sm = 0;
  for (i = 1; i <= n; i++) {
    scanf("%lld", &x);
    v[x].push_back(i);
    ar[i] = x;
    if (x) St.insert(x);
    if ((int)(St.size()) == m && f) {
      f = 0;
      lst = i;
    }
  }
  for (i = 1; i <= m; i++) {
    scanf("%lld", &x);
    br[i] = x;
    sm += x;
  }
  if (!lst || sm > n) {
    printf("-1\n");
    return 0;
  }
  long long lo = max(lst, sm);
  long long hi = n, ans = 2000000000LL;
  while (lo <= hi) {
    long long md = (lo + hi) >> 1LL;
    if (Ok(md)) {
      ans = min(ans, md);
      hi = md - 1LL;
    } else
      lo = md + 1;
  }
  if (ans == 2000000000LL) ans = -1LL;
  printf("%lld\n", ans);
  return 0;
}
