#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  vector<long long> b(m);
  long long f = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    --a[i];
  }
  long long sum = 0;
  for (long long i = 0; i < m; i++) {
    cin >> b[i];
    sum += b[i];
  }
  for (long long i = 0; i + sum <= n; i++) {
    vector<long long> c(m, 0);
    for (long long j = i; j < i + sum; j++) {
      c[a[j]]++;
    }
    long long fl = 1;
    for (long long k = 0; k < m; k++) {
      if (c[k] != b[k]) {
        fl = 0;
        break;
      }
    }
    if (fl == 1) {
      f = 1;
      break;
    }
  }
  if (f)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
