You are playing a game where your character should overcome different obstacles. The current problem is to come down from a cliff. The cliff has height $h$, and there is a moving platform on each height $x$ from $1$ to $h$.

Each platform is either hidden inside the cliff or moved out. At first, there are $n$ moved out platforms on heights $p_1, p_2, \dots, p_n$. The platform on height $h$ is moved out (and the character is initially standing there).

If you character is standing on some moved out platform on height $x$, then he can pull a special lever, which switches the state of two platforms: on height $x$ and $x - 1$. In other words, the platform you are currently standing on will hide in the cliff and the platform one unit below will change it state: it will hide if it was moved out or move out if it was hidden. In the second case, you will safely land on it. Note that this is the only way to move from one platform to another.

Your character is quite fragile, so it can safely fall from the height no more than $2$. In other words falling from the platform $x$ to platform $x - 2$ is okay, but falling from $x$ to $x - 3$ (or lower) is certain death. 

Sometimes it's not possible to come down from the cliff, but you can always buy (for donate currency) several magic crystals. Each magic crystal can be used to change the state of any single platform (except platform on height $h$, which is unaffected by the crystals). After being used, the crystal disappears.

What is the minimum number of magic crystal you need to buy to safely land on the $0$ ground level?


-----Input-----

The first line contains one integer $q$ ($1 \le q \le 100$) — the number of queries. Each query contains two lines and is independent of all other queries.

The first line of each query contains two integers $h$ and $n$ ($1 \le h \le 10^9$, $1 \le n \le \min(h, 2 \cdot 10^5)$) — the height of the cliff and the number of moved out platforms.

The second line contains $n$ integers $p_1, p_2, \dots, p_n$ ($h = p_1 > p_2 > \dots > p_n \ge 1$) — the corresponding moved out platforms in the descending order of their heights.

The sum of $n$ over all queries does not exceed $2 \cdot 10^5$.


-----Output-----

For each query print one integer — the minimum number of magic crystals you have to spend to safely come down on the ground level (with height $0$).


-----Example-----
Input
4
3 2
3 1
8 6
8 7 6 5 3 2
9 6
9 8 5 4 3 1
1 1
1

Output
0
1
2
0

Difficulty: interview

Starter code:

Solutions:
import sys
import math
from collections import defaultdict
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : list(map(int, input().split()))
def write(*args, sep="\n"):
  for i in args:
    sys.stdout.write("{}".format(i) + sep)
INF = float('inf')
MOD = int(1e9 + 7)

for q in range(int(input())):
  h, n = read()
  arr = list(read()) + [0]
  
  if n == 1:
    write(0)
    continue
  
  ans = 0

  cur = h 
  for i in range(1, n):
    if cur == arr[i]:
      continue
    else:
      if arr[i + 1] == arr[i] - 1:
        cur = arr[i] - 1
      else:
        ans += 1
  
  write(ans)
    


def mp():
    return map(int, input().split())

t = int(input())
for tt in range(t):
    h, n = mp()
    a = list(mp()) + [0]
    
    ans = 0
    last = h
    i = 1
    while i < n:
        #print('last =', last, '; i =', i, '; a[i] =', a[i], '; a[i + 1] =', a[i + 1], '; ans =', ans)
        last = min(last, a[i] + 1)
        if a[i + 1] == last - 2:
            last = a[i + 1]
            i += 2
        else:
            ans += 1
            last -= 2
            i += 1
    print(ans)

from sys import stdin,stdout
tests=int(stdin.readline().strip())
for t in range(tests):
    n,m=list(map(int,stdin.readline().strip().split()))
    s=list((list(map(int,stdin.readline().strip().split()))))
    s=s[::-1]
    cur=n
    ans=0
    while( cur>0) and len(s)!=0:
        if(cur<=2):
            break
        while len(s)>0 and s[-1]>=cur:
            s.pop()
        if(len(s)==0):
            break
        if cur-s[-1]>1:
            cur=s[-1]+1
            continue
        if len(s)==1:
            ans+=1
            break
        if (s[-2]+1)==s[-1]:
            cur=s[-2]
            continue
        ans+=1
        cur=s[-2]+1
    print(ans)


q=int(input())
for _ in range(q):
    h,n=[int(w) for w in input().split()]
    p=[int(w) for w in input().split()]
    p.append(0)
    r=0
    i=1
    while i<n:
        if p[i]==p[i+1]+1:
            i+=2
        else:
            i+=1
            r+=1
    print(r)


T = int(input())
for t in range(T):
    h,n = list(map(int,input().strip().split(' ')))
    steps = list(map(int,input().strip().split(' ')))
    steps.append(0)
    cur = n
    danger = 0
    ret = 0
    index = 1
    cur = steps[index] + 1
    while cur > 2:
        if steps[index+1] == cur - 2:
            index += 2
        else:
            index += 1
            ret += 1
        cur = steps[index] + 1
    print(ret)


import sys
def I():
    return sys.stdin.readline().rstrip()

q = int(I())
for _ in range(q):
    h, n = list(map( int, I().split() ))
    p = list(map(int,I().split()))
    i, ans = 0, 0
    while i < n:
        if h == p[ i ]:
            pass
        elif p[ i ] == 1:
            h = 0
        elif i < n - 1 and p[ i ] - 1 == p[ i + 1 ]:
            h = p[ i + 1 ]
        else:
            ans += 1
            h = p[ i ] - 1
        i += 1
    print( ans )


for _ in range(int(input())):
    h,n=map(int,input().split())
    p=list(map(int,input().split()))
    xyz=set(p)
    ans=0
    for i in p:
        if i<h:
            h=i+1
        if(h<=2):
            break
        if i==(h-1):
            if (h-2) in xyz:
                h-=2
            else:
                ans+=1
                h-=2
    print(ans)

q=int(input())
for i in range(q):
    h,n=map(int,input().split())
    p=list(map(int,input().split()))
    used=[0]
    for i in range(1,n):
        if i==1:
            used.append(1)
        else:
            if p[i]>=1:
                var=10000000000000
                if p[i-1]-p[i]==1:
                    used.append(used[i-2])
                else:
                    used.append(used[i-1]+1)
    i=n-1
    ans=0
    if p[i]>2:
        print(used[-1])
    else:
        if n>=2 and p[i]==1:
            print(min(used[-2],used[-1]))
        else:
            print(used[-1])

import sys
import math
input = sys.stdin.readline

q=int(input())
for i in range(q):
    h,n=list(map(int,input().split()))
    arr=list(map(int,input().split()))
    arr.append(0)
    count=0
    cur=0
    now=arr[cur]
    cur=1
    while cur<n:
       # print("now", now, "count", count)
        try:
            if now-arr[cur]==1:
                if now-arr[cur+1]==2:
                    now=arr[cur+1]
                    cur+=2
                else:
                    count+=1
                    now = arr[cur+1]+1
                    cur+=1
            else:
                now=arr[cur]+1
        except:
            break

    print(count)


q=int(input())
for i in range(q):
    h,n=[int(x) for x in input().split()]
    a=[int(x) for x in input().split()]+[10**10]
    counter=0
    arr=0
    for i in range(1,n+1):
        if a[i]==a[i-1]-1:
            counter+=1
        else:
            if counter%2==1 and a[i-1]!=1:
                arr+=1
            counter=1
    print(arr)


import sys
from collections import deque
input = sys.stdin.readline

def getcnt(fromplatform, toplatform):
    return (fromplatform-toplatform)//2

for _ in range(int(input())):
    h, n = list(map(int, input()[:-1].split()))
    platforms = deque(list(map(int, input()[:-1].split())))
    currenth = h
    platforms.popleft()
    platforms.append(-200)
    ans = 0
    while currenth > 2:        
        if currenth - 1 == platforms[0]:
            if currenth - 2 == platforms[1]:
                platforms.popleft()
                platforms.popleft()
                currenth-=2
            else:
                platforms.popleft()
                ans+=1
                currenth = platforms[0]+1
        else:
            currenth = platforms[0]+1
        #print(currenth)
    print(ans)



import bisect
import sys
input = sys.stdin.readline


q = int(input())
for _ in range(q):
    h, n = map(int, input().split())
    p = list(map(int, input().split())) + [0]
    cnt = 1
    ans = 0
    pos = h
    i = 1
    while True:
        if i >= n+1:
            break
        if pos == p[i] + 1:
            pos = p[i]
            cnt += 1
            i += 1
        else:
            pos = p[i] + 1
            if cnt % 2 == 0:
                ans += 1
                cnt = 1
    print(ans)

for itr in range(int(input())):
    h,o=list(map(int,input().split()))
    a=list(map(int,input().split()))
    a=a[::-1]
    a.pop(-1)
    ans=0
    while h>2:
        if len(a)==0: break
        if h-1==a[-1]:
            if len(a)>1 and h-2==a[-2]: 
                h-=2
                a.pop(-1)
                a.pop(-1)
            else:
                ans+=1
                h-=2
                a.pop(-1)
        else: h=a[-1]+1
    print(ans)

q = int(input())
for i in range(q):
    h, n = input().split()
    h = int(h)
    n = int(n)
    p = [int(j) for j in input().split()]+[0]
    s = 1
    a = 0
    for i in range(len(p)-1):
        if p[i]-p[i+1] >= 2 and s % 2 == 0:
            a += 1
            s = 2
        elif p[i]-p[i+1] >= 2 and s % 2 == 1:
            s = 2
        else:
            s += 1
    print(a)


q = int(input())
for _ in range(q):
    h, n = list(map(int, input().split()))
    ps = list(map(int, input().split())) + [0, 0]
    ps.reverse()
    cur = n-1
    crystals = 0
    while ps and ps[-1] > 1:
        if ps[-2] == h - 1:
            if ps[-3] == h - 2:
                ps.pop()
                ps.pop()
            else:
                ps.pop()
                ps[-1] = h - 2
                crystals += 1
            h -= 2
        else:
            ps[-1] = ps[-2] + 1
            h = ps[-1]
    print(crystals)


'''input
1
10000 7
10000 8 7 6 5 3 2
'''
# its a simulation
from sys import stdin
from bisect import bisect_left
    
     
# main starts
q = int(stdin.readline().strip())
for _ in range(q):
	h, n = list(map(int, stdin.readline().split()))
	moved = set(list(map(int, stdin.readline().split())))
	original = list(moved)
	original.sort()
	pos = h
	count = 0
	while pos > 0:
		# print('pos', pos, count)
		if pos - 1 in moved:
			if pos - 2 in moved:
				pos -= 2
					
			else:
				if pos - 2 != 0:
					count += 1
					pos -= 2
				else:
					pos -= 2

		else:
			index = bisect_left(original, pos)
			if index == 0:
				pos = 0
			else:
				pos = original[index - 1] + 1
			moved.add(pos)
	print(count)

import sys
input = sys.stdin.readline

q=int(input())

for testcases in range(q):
    h,n=list(map(int,input().split()))
    P=list(map(int,input().split()))
    P.append(-10)

    NOW=h
    ANS=0
    ind=1

    while NOW>=3:
        #print(NOW,ind,ANS)
        if P[ind]<NOW-1:
            NOW=P[ind]+1
            continue

        if P[ind]==NOW-1 and P[ind+1]==NOW-2:
            NOW-=2
            ind+=2
            continue

        if P[ind]==NOW-1 and P[ind+1]!=NOW-2:
            NOW-=2
            ind+=1
            ANS+=1


    print(ANS)
            
        
        

    


t = int(input())
while t > 0:
    t = t - 1
    hn = input().split()
    h = int(hn[0])
    n = int(hn[1])
    pos = input().split()
    pos = [int(val) for val in pos]
    curr = h
    curr_pos = 1
    no_crystal = 0
    while(curr > 2):
        if curr_pos >= len(pos):
            break
        if (curr - 1) == pos[curr_pos]:
            if(curr_pos == (len(pos) - 1) or (curr - 2) != pos[curr_pos + 1]):
                no_crystal = no_crystal + 1
                curr = curr - 2
                curr_pos = curr_pos + 1
            else:
                curr_pos = curr_pos + 2
        else:
            curr = pos[curr_pos] + 1
    print(no_crystal)

# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

for _ in range(INT()):
    H, N = MAP()
    A = LIST() + ([0]*2)

    ans = 0
    i = 0
    while i < N:
        if A[i+1] - A[i+2] <= 1:
            i += 2
        else:
            ans += 1
            A[i+1] += 1
            i += 1
    print(ans)


t = int(input())
for q in range(t):
    h, n = list(map(int, input().split()))
    p = list(map(int, input().split()))
    s = 0
    i = 1
    while h > 2 and i < n:
        if h - p[i] == 1:
            if i + 1 < n:
                if p[i] - p[i + 1] > 1: # falling down is not safe
                    s += 1
                    h = p[i] - 1
                    i += 1
                else: # falling down is safe
                    h = p[i + 1]
                    i += 2
            else: # falling down is not restrickted by the lower platform
                if p[i] == 1:
                    h = 0
                else:
                    s += 1
                    h = p[i] - 1
                    i += 1
        else:
            h = p[i] + 1
    print(s)


import sys

q = int(input())
for _ in range(q):
  h, n = list(map(int, sys.stdin.readline().split()))
  p = iter(list(map(int, sys.stdin.readline().split())) + [0])
  cost = 0
  akt = next(p)
  a = next(p)
  if a == 0:
    print(0)
  else:
    b = next(p)
    while True:
      if a-b == 1:
        akt = b
        if akt == 0:
          break
        else:
          a = next(p)
        if a == 0:
          break
        else:
          b = next(p)
      else:
        cost += 1
        akt = a-1
        a = b
        if a == 0:
          break
        else:
          b = next(p)
    print(cost)


t= int(input())
for _ in range(t):
    h, n =  list(map(int, input().split()))
    p= list(map(int,input().split()))
    p.reverse()
    s=n-1
    # print(s)
    c=0
    l=h
    while 1:
        if l<3:
            break
        if s<1:
            break
        if l -p[s-1]>1:
            l= p[s-1]+1
        elif s<2:
            if p[s]-2 >0:
                c+=1
            break
        elif l-p[s-2]==2:
            l=p[s-2]
            s-=2
        else:
            c+=1
            l-=2
            s-=1
    print(c)


q = int(input())

for _ in range(q):
    h, n = list(map(int, input().split()))

    p = list(map(int, input().split()))[1:]
    dangers = []

    rows = 1
    i = 0
    while i < len(p):
        if i > 0 and p[i] == p[i - 1] - 1:
            rows += 1
        else:
            rows = 1

        if (i == len(p) - 1 or p[i + 1] != p[i] - 1) and p[i] > 1:
            if rows % 2:
                dangers.append(p[i])
        #print(rows, i, p[i])
        i += 1
   
    print(len(dangers))


q = int(input())
for i in range(q):
	inp = input()
	inp_arr = inp.split(" ")
	h = int(inp_arr[0])
	n = int(inp_arr[1])
	inp_p = input()
	inp_p_arr = inp_p.split(" ")
	inp_p_arr = [int(j) for j in inp_p_arr]
	inp_p_arr.append(0)
	count = 0
	par_che = 1
	for j in range(1, n):
		if inp_p_arr[j]-inp_p_arr[j+1] == 1:
			par_che += 1
		else:
			if par_che %2==1:
				count+=1
			par_che = 1

	print(count)