#include <bits/stdc++.h>
using namespace std;
long long int n, m, a[200000], sum = 0, last_sub[200000], at_sub[200000],
                               b[200000];
bool check(long long int i) {
  memset(last_sub, 0, sizeof(last_sub));
  memset(at_sub, 0, sizeof(at_sub));
  long long int j, k, p, q, r, free = 0;
  for (j = 1; j <= i; j++) {
    last_sub[a[j]] = j;
  }
  for (j = 1; j <= m; j++) {
    if (last_sub[j] == 0) return false;
    at_sub[last_sub[j]] = j;
  }
  for (j = 1; j <= i; j++) {
    if (at_sub[j] == 0)
      free++;
    else if (b[at_sub[j]] > free)
      return false;
    else
      free -= b[at_sub[j]];
  }
  return true;
}
int main() {
  long long int i, j, k, l, p, q, r, mid, ans = -1;
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= m; i++) {
    cin >> p;
    b[i] = p;
  }
  l = 1;
  r = n;
  while (l <= r) {
    mid = (l + r) / 2;
    if (check(mid)) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  cout << ans << "\n";
  return 0;
}
