#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int a[N], cnt[N], b[N];
int n, m;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      memset(cnt, 0, sizeof cnt);
      for (int k = i; k <= j; k++) cnt[a[k]]++;
      bool flag = 0;
      for (int k = 1; k <= m; k++)
        if (b[k] != cnt[k]) flag = 1;
      if (!flag) {
        return puts("YES"), 0;
      }
    }
  }
  return puts("NO"), 0;
}
