#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 2;
int n, m, a[N], k[N], kol[N], sum;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) {
    cin >> k[i];
    sum += k[i];
  }
  for (int i = 1; i <= sum; i++) kol[a[i]]++;
  for (int i = sum; i <= n; i++) {
    int fl = 1;
    for (int j = 1; j <= m; j++) {
      if (kol[j] != k[j]) fl = 0;
    }
    if (fl) {
      puts("YES");
      return 0;
    }
    if (i > sum) {
      kol[a[i]]++;
      kol[a[i - sum]]--;
    }
  }
  bool fl = 1;
  for (int j = 1; j <= m; j++) {
    if (kol[j] != k[j]) fl = 0;
  }
  if (fl) {
    puts("YES");
  } else
    puts("NO");
}
