#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 2e5 + 5;
const long double pi = 3.14159265;
long long gcd(long long a_, long long b_) {
  if (b_ > a_) swap(b_, a_);
  return (b_ == 0 ? a_ : gcd(b_, a_ % b_));
}
long long u[N], n, k[N], t[N], m, id, c, kk, ans = 0;
void add(long long x) {
  if (t[x] == k[x]) c--;
  t[x]++;
  if (t[x] == k[x]) c++;
}
void sub(long long x) {
  if (t[x] == k[x]) c--;
  t[x]--;
  if (t[x] == k[x]) c++;
}
void ch() {
  if (c == m) ans = 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> u[i];
  }
  for (long long i = 1; i <= m; i++) {
    cin >> k[i];
    if (!k[i]) c++;
    kk += k[i];
  }
  for (long long i = 0; i < kk; i++) {
    add(u[i]);
  }
  id = kk;
  ch();
  while (id <= n) {
    ch();
    if (id == n) break;
    add(u[id]);
    sub(u[id - kk]);
    id++;
  }
  cout << (ans ? "YES" : "NO");
  return 0;
}
