#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m;
int d[N];
int a[N];
int lp[N];
vector<pair<int, int>> lpv;
bool ok(int days) {
  bool vis[N];
  days = min(days, n);
  bool ready[N];
  int counter[N];
  memset(ready, 0, sizeof ready);
  memset(counter, 0, sizeof counter);
  memset(vis, 0, sizeof vis);
  int j = 0;
  lpv.clear();
  for (int i = 0; i <= n; i++) {
    lp[i] = -1;
  }
  for (int i = 1; i <= days; i++) {
    int can = d[i];
    lp[can] = i;
  }
  for (int i = 1; i <= m; i++) {
    if (lp[i] == -1) return false;
    lpv.push_back({lp[i], i});
  }
  sort(lpv.begin(), lpv.end());
  int done = 0;
  for (int i = 1; i <= days; i++) {
    if (ready[d[i]] && !vis[d[i]]) {
      done++;
      vis[d[i]] = 1;
      if (done == m) {
        break;
      }
      continue;
    }
    if (j == m) continue;
    if (counter[lpv[j].second] < a[lpv[j].second]) {
      counter[lpv[j].second]++;
      if (counter[lpv[j].second] == a[lpv[j].second]) {
        ready[lpv[j].second] = 1;
        j++;
      }
    }
  }
  if (done == m)
    return true;
  else
    return false;
}
int BS() {
  int lo = 1, hi = 1e6, mid;
  while (lo < hi) {
    mid = (lo + hi) / 2;
    if (ok(mid))
      hi = mid;
    else
      lo = mid + 1;
  }
  return lo;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> a[i];
  }
  int x = BS();
  if (x <= n)
    cout << x << endl;
  else
    cout << -1 << endl;
  return 0;
}
