#include <bits/stdc++.h>
using namespace std;
long long dp[200000];
int a[200000], v[200000];
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; i++) cin >> dp[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) v[j] = 0;
    for (int j = i; j <= n; j++) {
      v[a[j]]++;
      int f = 0;
      for (int k = 1; k <= m; k++) {
        if (v[k] != dp[k]) {
          f = 1;
          break;
        }
      }
      if (!f) {
        cout << "YES";
        return 0;
      }
    }
  }
  cout << "NO";
  return 0;
}
