#include <bits/stdc++.h>
using namespace std;
int n, m, d[100005], a[100005], c[100005];
vector<int> v[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    v[d[i]].push_back(i);
  }
  for (int i = 1; i <= m; i++) cin >> a[i];
  int lo = 1, hi = n + 1, mid, ans = -1;
  while (lo < hi) {
    mid = (lo + hi) / 2;
    int foo = 1;
    for (int i = 1; i <= m; i++) {
      int idx = upper_bound(v[i].begin(), v[i].end(), mid) - v[i].begin() - 1;
      if (idx >= 0) {
        c[i] = v[i][idx];
      } else {
        foo = 0;
        break;
      }
    }
    if (foo == 0) {
      lo = mid + 1;
      continue;
    }
    int time = 0;
    vector<pair<int, int> > v1;
    for (int i = 1; i <= m; i++) {
      v1.push_back(make_pair(c[i], i));
    }
    sort(v1.begin(), v1.end());
    for (int i = 0; i <= m - 1; i++) {
      if (v1[i].first - 1 - time >= a[v1[i].second]) {
        time += a[v1[i].second] + 1;
      } else {
        foo = 0;
        break;
      }
    }
    if (time > mid) foo = 0;
    if (foo)
      ans = mid, hi = mid;
    else
      lo = mid + 1;
  }
  cout << ans;
  return 0;
}
