#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T amax(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, x;
  cin >> n >> m;
  long long a[n + 1], b[m + 1];
  map<long long, long long> mp;
  for (long long i = 1; i < n + 1; i++) {
    cin >> x;
    a[i] = x;
  }
  for (long long i = 1; i < m + 1; i++) cin >> b[i];
  for (long long i = 1; i <= n; i++) {
    for (long long j = i; j <= n; j++) {
      for (long long k = i; k <= j; k++) {
        mp[a[k]]++;
      }
      long long f = 0;
      for (long long k = 1; k <= m; k++) {
        if (mp[k] != b[k]) {
          f = 1;
          break;
        }
      }
      if (f == 0) {
        cout << "YES" << endl;
        return 0;
      }
      mp.clear();
    }
  }
  cout << "NO" << endl;
}
