#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long int B[2000010], A[2000010], C[2000010], D[2000010];
long long int n, m, p, q;
vector<long long int> V[2000010];
long long int powP(long long int a, long long int b) {
  if (b == 0) return 1 % mod;
  long long int k;
  k = powP(a, b / 2);
  k = k * k % mod;
  if (b % 2 == 0)
    return k;
  else
    return a * k % mod;
}
bool bitSet(long long int n, long long int i) {
  if ((n & (1 << i)) != 0)
    return true;
  else
    return false;
}
void mmod(long long int& cur) {
  while (cur >= mod) {
    cur -= mod;
  }
}
bool check(long long int k) {
  for (long long int i = (1); i <= (k); ++i) B[i] = 0;
  for (long long int i = (1); i <= (n); ++i) {
    long long int t = V[i].size();
    if (t == 0) return false;
    long long int x = -1;
    if (V[i][t - 1] <= k) x = t - 1;
    for (long long int j = (0); j <= (t - 1); ++j) {
      if (V[i][j] > k) {
        x = j - 1;
        break;
      }
    }
    if (x == -1) return false;
    B[V[i][x]] = i;
  }
  long long int val = 0;
  for (long long int i = (1); i <= (k); ++i) {
    if (B[i] == 0)
      val++;
    else {
      long long int t = B[i];
      if (A[t] > val) return false;
      val -= A[t];
    }
  }
  return true;
}
int main() {
  long long int T, i, j, h, l, r, k, s, b, c, a, d, w, x, y, v, z, t, curr,
      prev, sum, ans, pos, val, countA, secondMin, indicator;
  scanf("%lld%lld", &m, &n);
  for (long long int i = (1); i <= (m); ++i) {
    scanf("%lld", &j);
    if (j != 0) V[j].push_back(i);
  }
  for (long long int i = (1); i <= (n); ++i) scanf("%lld", &A[i]);
  long long int low = n, high = m, mid;
  ans = -1;
  while (high - low >= 0) {
    mid = low + (high - low) / 2;
    if (check(mid)) {
      ans = mid;
      high = mid - 1;
    } else
      low = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
