#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> jedis(n, 0), colors(m, 0);
  for (int i = 0; i < n; ++i) cin >> jedis[i];
  int colors_sum = 0;
  for (int i = 0; i < m; ++i) {
    cin >> colors[i];
    colors_sum += colors[i];
  }
  for (int i = 0; i < n - colors_sum + 1; ++i) {
    vector<int> used(m + 1, 0);
    for (int j = i; j < i + colors_sum; ++j) ++used[jedis[j]];
    bool equal = true;
    for (int j = 0; j < m; ++j)
      if (used[j + 1] != colors[j]) equal = false;
    if (equal) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}
