#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<int> k(m, 0);
  for (int i = 0; i < m; i++) cin >> k[i];
  bool can = false;
  for (int i = 0; i < n; i++) {
    int cnt = m;
    vector<int> p(m, 0);
    for (int j = 0; j < m; j++)
      if (p[j] == k[j]) cnt--;
    for (int j = i; j < n; j++) {
      p[a[j]]++;
      if (p[a[j]] > k[a[j]]) break;
      if (p[a[j]] == k[a[j]]) cnt--;
      if (cnt == 0) can = true;
    }
  }
  if (can) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
