#include <bits/stdc++.h>
using namespace std;
int kn[10100];
int mk[10100];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &kn[i]);
  }
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &mk[i]);
    sum += mk[i];
  }
  bool flag = 0;
  for (int i = 1; i <= n; i++) {
    if (i <= sum) {
      mk[kn[i]]--;
      bool now = 1;
      for (int j = 0; j <= n; j++) {
        if (mk[j] != 0) now = 0;
      }
      if (now) flag = 1;
    } else {
      mk[kn[i]]--;
      mk[kn[i - sum]]++;
      bool now = 1;
      for (int j = 0; j <= n; j++) {
        if (mk[j] != 0) now = 0;
      }
      if (now) flag = 1;
    }
  }
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
