#include <bits/stdc++.h>
using namespace std;
long long a, b, c[1234567], d[1234567], c1[1234][1234], e[1234567], n, j, i, l,
    r, x, y, k, ans;
bool used[1234567];
long long T;
int main() {
  cin >> n >> k;
  map<long long, long long> m;
  for (long long i = 1; i <= n; i++) {
    cin >> d[i];
  }
  for (long long i = 1; i <= k; i++) {
    cin >> e[i];
  }
  for (long long i = 1; i <= n; i++) {
    memset(c, 0, sizeof c);
    for (long long j = i; j <= n; j++) {
      c[d[j]]++;
      bool ok = true;
      for (long long o = 1; o <= k; o++) {
        if (c[o] != e[o]) {
          ok = false;
          break;
        }
      }
      if (ok) {
        puts("YES");
        exit(0);
      }
    }
  }
  cout << "NO";
}
