#include <bits/stdc++.h>
using namespace std;
long long a[100010], b[100010];
map<long long, long long> ma;
map<long long, long long> mma;
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long sum = 0;
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    sum += b[i];
    ma[i] += b[i];
  }
  long long l = 0, r = sum;
  while (r <= n) {
    bool is = 1;
    for (int i = l; i < r; i++) {
      mma[a[i]]++;
    }
    for (int j = 1; j <= m; j++) {
      if (ma[j] != mma[j]) {
        is = 0;
      }
    }
    l++;
    r++;
    mma.clear();
    if (is == 1) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
