#include <bits/stdc++.h>
using namespace std;
const int mm = 2e5 + 100;
long long int d[mm], ans[mm];
long long int num[1000];
vector<long long int> v[mm];
int main() {
  long long int n, m, i, j, t, a, b, c, p, k, kk, z;
  scanf("%lld%lld", &n, &m);
  long long int sum = 0;
  for (i = 1; i <= n; i++) scanf("%lld", &d[i]), num[i] = 0;
  for (i = 1; i <= m; i++) scanf("%lld", &ans[i]), sum += ans[i];
  long long int o = 0;
  for (i = 1; i <= n; i++) {
    p = 0;
    memset(num, 0, sizeof(num));
    for (j = 0, z = i; j < sum; j++, z++) {
      num[d[z]]++;
    }
    for (j = 1; j <= m; j++) {
      if (ans[j] == num[j])
        p++;
      else
        break;
    }
    if (p == m) {
      o = 1;
      break;
    }
  }
  if (o)
    printf("YES\n");
  else
    printf("NO\n");
}
