#include <bits/stdc++.h>
using namespace std;
int a[1000], b[1000], c[1000];
int n, m;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    sum += b[i];
  }
  for (int i = 0; i < n - sum + 1; i++) {
    for (int j = 1; j <= n; j++) c[j] = 0;
    for (int j = i; j < sum + i; j++) c[a[j]]++;
    int ans = 1;
    for (int j = 1; j <= m; j++) ans = ans & (b[j] == c[j]);
    if (ans) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}
