#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
long long int tar[100], cur[100];
bool check(long long int n) {
  for (long long int i = 0; i < n; i++)
    if (tar[i] != cur[i]) return 0;
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  for (long long int i = 0; i < m; i++) cin >> tar[i];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) cur[j] = 0;
    for (long long int j = i; j < n; j++) {
      cur[arr[j] - 1]++;
      if (check(m)) {
        cout << "YES\n";
        return 0;
      }
    }
  }
  cout << "NO\n";
  return 0;
}
