#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
int N, M, C;
int A[MAXN];
int K[MAXN];
int diff[MAXN];
int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    A[i]--;
  }
  for (int i = 0; i < M; i++) {
    scanf("%d", &K[i]);
    C += K[i];
  }
  multiset<int> st;
  for (int i = 0; i < M; i++) {
    diff[i] = -K[i];
    st.insert(diff[i]);
  }
  int ans = INT_MAX;
  for (int i = 0, j = 0; i < N; i++) {
    while (j < N && *st.begin() < 0) {
      int &ref = diff[A[j]];
      st.erase(st.find(ref));
      ref++;
      st.insert(ref);
      j++;
    }
    if (*st.begin() < 0) {
      break;
    }
    ans = min(ans, j - i - C);
    int &ref = diff[A[i]];
    st.erase(st.find(ref));
    ref--;
    st.insert(ref);
  }
  if (ans == INT_MAX) {
    ans = -1;
  }
  printf("%d\n", ans);
}
