#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000 + 10;
const int INF = 1e9;
int n, m, a[MAX_N];
vector<pair<int, int> > v;
vector<int> jobs[MAX_N];
bool mark[MAX_N];
bool check(int K) {
  v.clear();
  for (int i = 0; i < MAX_N; i++) mark[i] = false;
  for (int i = 1; i <= m; i++) {
    if (jobs[i].size() == 0) return false;
    for (int j = 0; j < jobs[i].size(); j++) {
      if (jobs[i][j] > K) {
        if (j == 0) return false;
        v.push_back(make_pair(jobs[i][j - 1], i));
        break;
      }
    }
    if (v.size() != i) v.push_back(make_pair(jobs[i][jobs[i].size() - 1], i));
  }
  sort(v.begin(), v.end());
  int cur = 1;
  int jj = 0;
  while (jj < v.size()) {
    int time = v[jj].first;
    int job = v[jj].second;
    for (int j = 1; j <= a[job];) {
      if (mark[cur]) {
        cur++;
        continue;
      }
      cur++;
      j++;
    }
    if (cur > time) return false;
    mark[time] = 1;
    jj++;
  }
  return true;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    jobs[x].push_back(i);
  }
  for (int i = 1; i <= m; i++) scanf("%d", &a[i]);
  int low = 0;
  int high = n;
  int ans = -1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (check(mid)) {
      ans = mid;
      high = mid - 1;
    } else
      low = mid + 1;
  }
  printf("%d", ans);
}
