#include <bits/stdc++.h>
using namespace std;
const int nmax = 2 * 1e5 + 100;
const int INF = 0x3f3f3f3f;
struct cmp {
  bool operator()(pair<int, int> a, pair<int, int> b) {
    return a.first > b.first;
  }
};
struct cmp2 {
  bool operator()(pair<int, int> a, pair<int, int> b) {
    return a.first < b.first;
  }
};
vector<int> v[nmax];
priority_queue<pair<int, int>, vector<pair<int, int> >, cmp> f;
priority_queue<pair<int, int>, vector<pair<int, int> >, cmp2> b;
pair<int, int> ff, bb, temp;
int n, m, sum;
int cnt[nmax];
int k[nmax];
int l[nmax], r[nmax];
bool isok = true, notfind = false;
void init() {
  for (int i = 1; i <= m; ++i) {
    l[i] = 0;
    r[i] = 0 + k[i] - 1;
    if (k[i]) f.push(make_pair(v[i][l[i]], i));
    if (k[i]) b.push(make_pair(v[i][r[i]], i));
  }
}
void change() {
  if (!f.empty())
    f.pop();
  else {
    isok = false;
    return;
  }
  if (l[temp.second] + 1 < v[temp.second].size() &&
      r[temp.second] + 1 < v[temp.second].size()) {
    l[temp.second]++, r[temp.second]++;
    f.push(make_pair(v[temp.second][l[temp.second]], temp.second));
    b.push(make_pair(v[temp.second][r[temp.second]], temp.second));
    return;
  } else {
    notfind = true;
    ff.first = min(ff.first, temp.first);
    return;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  int h;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &h);
    v[h].push_back(i);
    cnt[h]++;
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &k[i]);
    sum += k[i];
  }
  bool isenough = true;
  for (int i = 1; i <= m; ++i) {
    if (cnt[i] < k[i]) {
      isenough = false;
      break;
    }
  }
  if (!isenough)
    printf("-1\n");
  else {
    int ans = INF;
    init();
    ff.first = INF;
    while (isok) {
      temp = f.top();
      if (!notfind) ff.first = temp.first;
      bb = b.top();
      ans = min(ans, bb.first - ff.first + 1 - sum);
      change();
    }
    printf("%d\n", ans);
  }
  return 0;
}
