#include <bits/stdc++.h>
using namespace std;
vector<int> g[1005];
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> v;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  for (int i = 1; i <= m; i++) {
    int x;
    cin >> x;
    mp[i] = x;
  }
  for (int i = 0; i < n; i++) {
    map<int, int> mp1;
    for (int j = 0; j <= i; j++) mp1[v[j]]++;
    map<int, int>::iterator itr;
    int f = 0;
    for (itr = mp.begin(); itr != mp.end(); itr++) {
      if (itr->second == mp1[itr->first])
        continue;
      else {
        f = 1;
        break;
      }
    }
    if (f == 0) {
      cout << "YES" << endl;
      return;
    } else {
      f = 0;
      for (int j = 1; j < n - i; j++) {
        mp1[v[j - 1]]--;
        mp1[v[j + i]]++;
        f = 0;
        for (itr = mp.begin(); itr != mp.end(); itr++) {
          if (itr->second == mp1[itr->first])
            continue;
          else {
            f = 1;
            break;
          }
        }
        if (f == 0) {
          cout << "YES";
          return;
        }
      }
    }
  }
  cout << "NO";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
