#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int inf = 0x7f7f7f7f;
const int MOD = 1000000007;
int ex[maxn];
int num[maxn];
int vis[maxn];
int check(int d) {
  memset(vis, 0, sizeof(vis));
  int sum = 0;
  int nn = 0;
  int pos = -1;
  for (int i = d; i >= 1; i--) {
    if (ex[i] && vis[ex[i]] == 0) {
      if (pos != -1) nn -= (pos - i - 1);
      if (num[ex[i]] + 1 > i - nn)
        return 0;
      else {
        vis[ex[i]] = 1;
        pos = i;
        sum++;
        nn += num[ex[i]];
      }
    }
  }
  return sum;
}
int main() {
  int n, m;
  cin >> n >> m;
  long long sum = m;
  for (int i = 1; i <= n; i++) scanf("%d", ex + i);
  for (int i = 1; i <= m; i++) {
    scanf("%d", num + i);
    sum += num[i];
  }
  int ans = -1;
  int l = 1, r = n;
  while (l <= r) {
    int mid = l + r >> 1;
    int nn = check(mid);
    if (nn == m) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%d\n", ans);
}
