#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  long long int a[n + 1], b[m + 1], need = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    need += b[i];
  }
  vector<long long int> cnt(m + 5, 0), found(m + 5, 0);
  for (int i = 1; i <= n; i++) {
    cnt[a[i]]++;
    if (i - 1 >= b[a[i]]) {
      found[a[i]] = 1;
    }
  }
  long long int ans = -1;
  for (int i = 1; i <= m; i++) {
    if (!cnt[i] || !found[i]) {
      cout << "-1\n";
      return 0;
    }
  }
  for (int i = n; i >= 1; i--) {
    if (a[i] != 0) {
      if (i - m >= need) {
        ans = i;
      }
      cnt[a[i]]--;
      if (cnt[a[i]] == 0) {
        break;
      }
    }
  }
  cout << ans;
  return 0;
}
