#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3c3c3c3c3c3c3c3c;
const int MAX_N = 1e5 + 9;
int D[MAX_N], A[MAX_N];
vector<int> adj[MAX_N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) adj[i].push_back(0);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &D[i]);
    adj[D[i]].push_back(i);
  }
  for (int i = 1; i <= m; i++) scanf("%d", &A[i]);
  int left = 0, right = n + 1;
  while (left + 1 < right) {
    priority_queue<pair<int, int>> pq;
    int mid = (left + right) / 2;
    bool is = true;
    for (int i = 1; i <= m; i++) {
      int p =
          lower_bound(adj[i].begin(), adj[i].end(), mid + 1) - adj[i].begin();
      pq.push({-adj[i][p - 1], i});
    }
    int used = 0;
    while (!pq.empty()) {
      auto t = pq.top();
      int p = -t.first, s = t.second;
      pq.pop();
      if (A[s] + used < p)
        used += A[s] + 1;
      else {
        is = false;
        break;
      }
    }
    if (is)
      right = mid;
    else
      left = mid;
  }
  printf("%d", right <= n ? right : -1);
}
