func_code_string: #include <bits/stdc++.h>   using namespace std;   struct IO {     char buf[(1 << 20)], *p1, *p2;     char pbuf[(1 << 20)], *pp;     IO() : p1(buf), p2(buf), pp(pbuf) {}     inline char gc() {       return getchar();       if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, (1 << 20), stdin);       return p1 == p2 ?     : *p1++;     }     inline bool blank(char ch) {       return ch ==     || ch ==   n  || ch ==   r  || ch ==   t ;     }     template <class T>     inline void read(T &x) {       register double tmp = 1;       register bool sign = 0;       x = 0;       register char ch = gc();       for (; !(ch >=  0  && ch <=  9 ); ch = gc())         if (ch ==  - ) sign = 1;       for (; (ch >=  0  && ch <=  9 ); ch = gc()) x = x * 10 + (ch -  0 );       if (ch ==  . )         for (ch = gc(); (ch >=  0  && ch <=  9 ); ch = gc())           tmp /= 10.0, x += tmp * (ch -  0 );       if (sign) x = -x;     }     inline void read(char *s) {       register char ch = gc();       for (; blank(ch); ch = gc())         ;       for (; !blank(ch); ch = gc()) *s++ = ch;       *s = 0;     }     inline void read(char &c) {       for (c = gc(); blank(c); c = gc())         ;     }     template <class t>     inline void write(t x) {       if (x < 0)         putchar( - ), write(-x);       else {         if (x > 9) write(x / 10);         putchar( 0  + x % 10);       }     }   } io;   const int mod = 1e9 + 7;   const int mo = 998244353;   const int N = 5e5 + 5;   int n, m, a[N], b[N], c[N], stak[N], gs, ans;   inline int get(int l, int r) {     int top = 0;     for (int i = (l); i <= (r); i++) {       if (a[i] < a[l] || a[i] > a[r]) continue;       if (!top || a[i] >= stak[top])         stak[++top] = a[i];       else {         int p = upper_bound(stak + 1, stak + top + 1, a[i]) - stak;         stak[p] = a[i];       }     }     return top;   }   int main() {     io.read(n), io.read(m);     for (int i = (1); i <= (n); i++) io.read(a[i]), a[i] = a[i] - i + 1;     for (int i = (1); i <= (n); i++) b[i] = a[i];     a[++n] = 2e9, b[n] = 2e9;     sort(b + 1, b + n + 1);     gs = unique(b + 1, b + n + 1) - b - 1;     for (int i = (1); i <= (n); i++)       a[i] = lower_bound(b + 1, b + gs + 1, a[i]) - b;     for (int i = (1); i <= (m); i++) io.read(b[i]);     for (int i = (2); i <= (m); i++)       if (a[b[i - 1]] > a[b[i]]) ans = -1;     if (ans == -1) return puts( -1 ), 0;     b[0] = 0, b[m + 1] = n;     ans = 0;     for (int i = (0); i <= (m); i++)       ans += b[i + 1] - b[i] + 1 - get(b[i], b[i + 1]);     io.write(ans), puts(  );     return 0;   }   