#include <bits/stdc++.h>
using namespace std;
const long long ma = 128 * 1024;
int n, m;
vector<int> a, k;
int main() {
  iostream::sync_with_stdio(0);
  cin >> n >> m;
  a.resize(n);
  k.resize(m);
  for (int i = 0; i < int(n); i++) {
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < int(m); i++) cin >> k[i];
  for (int i = 0; i < int(n); i++) {
    vector<int> cnt(m, 0);
    for (int j = i; j < n; j++) {
      cnt[a[j]]++;
      bool ok = true;
      for (int q = 0; q < int(m); q++)
        if (cnt[q] != k[q]) ok = false;
      if (ok) {
        cout << "YES\n";
        return 0;
      }
    }
  }
  cout << "NO\n";
}
