#include <bits/stdc++.h>
using namespace std;
int constexpr N = 300009;
int n, m, a[N], k[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int needed = 0;
  for (int j = 1; j <= m; ++j) cin >> k[j], needed += k[j];
  int ans = 1e9, total = needed;
  for (int p1 = 1, p2 = 1; p1 <= n;) {
    while (p2 <= n) {
      int col = a[p2];
      k[col]--;
      if (k[col] >= 0) needed--;
      p2++;
      if (needed == 0 || p2 > n) {
        break;
      }
    }
    if (needed == 0) {
      ans = min(ans, (p2 - p1) - total);
    }
    while (p1 <= n) {
      int col = a[p1];
      k[col]++;
      p1++;
      if (k[col] > 0) needed++;
      if (needed == 0) ans = min(ans, (p2 - p1) - total);
      if (needed > 0 || p1 == p2) break;
    }
  }
  cout << (ans == 1e9 ? -1 : ans) << endl;
}
