#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
int n, m;
int a[maxn], b[maxn];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  int ans = m, cs = 0;
  for (int i = 1; i <= m; ++i) {
    cin >> b[i];
    cs += b[i];
    b[i] = -b[i];
    if (b[i] == 0) ans--;
  }
  int len = 0x3f3f3f3f;
  int l = 1;
  for (int i = 1; i <= n; ++i) {
    b[a[i]]++;
    if (b[a[i]] == 0) {
      ans--;
    }
    while (ans == 0) {
      len = min(len, i - l + 1);
      b[a[l]]--;
      if (b[a[l]] == -1) {
        ans++;
      }
      l++;
    }
  }
  if (len == 0x3f3f3f3f) {
    cout << -1 << endl;
    return 0;
  }
  cout << len - cs << endl;
  return 0;
}
