#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000000,102400000000")
const long long MOD = 1000000007;
const int N = 1e5 + 5;
const int maxn = 2e5 + 15;
const int letter = 130;
const long long INF = (1ll << 63) - 1;
const double pi = acos(-1.0);
const double eps = 1e-13;
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, d[N], a[N], vis[N], dis[N], ps[N];
bool check(int x) {
  int sum = x;
  memset(dis, 0, sizeof(dis));
  for (int i = x; i >= 1; i--) {
    if (!dis[d[i]] && d[i]) dis[d[i]] = i;
  }
  int id = x, cnt = 0;
  for (int i = x; i >= 1; i--) {
    if (d[i] && dis[d[i]] == i) {
      int sum = a[d[i]];
      while (id && sum > 0) {
        if (dis[d[id]] != id) sum--;
        id--;
      }
      if (sum > 0)
        return 0;
      else
        cnt++;
    } else {
      if (id > i)
        while (id != i) id--;
    }
  }
  if (cnt != m) return 0;
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", d + i);
  for (int i = 1; i <= m; i++) scanf("%d", a + i);
  int l = 1, r = n, mid;
  int ans = -1;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%d\n", ans);
  return 0;
}
